Skip to content

Instantly share code, notes, and snippets.

@qrohlf
Last active July 26, 2016 18:31
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save qrohlf/7045823 to your computer and use it in GitHub Desktop.
Save qrohlf/7045823 to your computer and use it in GitHub Desktop.
Ruby Hello World
  = 1
   =  + 
    =   *  + 
     =    *  
      =
[     *(   +  )+  ,
        =     *    + ,
         =     *    +    -  ,
        ,
        =        +    ,
    *  +    +  ,
    *    -  *    +   +  ,
       ,
       + +  ,
        ,
    *    ,     + +  ,
    ]
puts      .map(&:chr).join
@mvidner
Copy link

mvidner commented Jan 29, 2016

Nice! Here's a readability trick:

ruby -p -e '$_.gsub!(/ +/," ").gsub!(/\u00a0+/){|m| "v#{m.size}"}' < helloworld 

prints

v1 = 1
v2 = v1+v1
v3 = v2*v2+v1
v4 = v3*v2
v5 = 
 [v4 *(v3+v2)+v2, 
 v7 = v4*v4+v1, 
 v8 = v4*v4+v4-v2, 
 v8, 
 v7 = v7+v4,
 v4*v2+v4+v2, 
 v4*v4-v2*v4+v3+v2, 
 v7, 
 v7+v1+v2, 
 v8, 
 v4*v4, v4+v1+v2, 
 v4]
puts v5.map(&:chr).join

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment