Skip to content

Instantly share code, notes, and snippets.

@4hg
Last active April 9, 2023 21:27
Show Gist options
  • Save 4hg/0a0ebe2e36ddda95eaa7ef7bbfa1890c to your computer and use it in GitHub Desktop.
Save 4hg/0a0ebe2e36ddda95eaa7ef7bbfa1890c to your computer and use it in GitHub Desktop.

A collection of my submissions to http://golf.shinh.org/.

Each are as-is post mortem, therefore most could be improved.

J

echo(toupper a{~c)(c=:I.'#'=stdin'')}a=:433$LF,~30$'helloworld'

Ruby

$<.bytes{|b|putc ($/+"helloworld"*3)[$.%31]-b[0]*32;$.+=1}

Ruby2

$<.bytes{|b|putc ($/+"helloworld"*3)[($.+=1)%31].ord-b[0]*32}

Ruby2

20.times{|n|puts (("%20s".%"1"*-~n).chars.rotate(-$.+=n+1)*'').rstrip}

Ruby

(a=[(c="Happy birthday")+" to you"]*4)[gets.to_i-1]=c+" dear anagol"
$><<a*",
"+"!"

J

wd&>'Hello, World!';(,.i.10);1!:1]3

Ruby

puts"Hello, World!",[*0..9],*$<

Ruby2

puts"Hello, World!",*0..9,*$<

Ruby2

a=eval *$<
0while a[p~-$.+=a[~-$.]]

Ruby

$<.map{|a|9.times{|c|a[c]>90&&putc('CHRISTMAS'[c])};puts}

Ruby2

$<.map{|a|9.times{|c|a[c]>?Z&&$><<'CHRISTMAS'[c]};puts}

Ruby2

$<.bytes{|c|$.+=-c%45-1;(0..6)===$.?$><<'0*12345'[$.]:break}

J

xnor=.=
wd@".;._1(,stdin)LF

J

(wd@#~"+96|3&u:)1!:1]3

Ruby

$<.chars{|c|puts c.*c[0]%96}

Ruby2

$<.bytes{|c|puts c.chr.*c%96}

J

wd'cya'42 69}100 3$'bye'

Ruby2

s=[:bye]*100
s[42]=s[69]=:cya
puts s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment