Last active
August 29, 2015 14:00
-
-
Save robmiller/11408754 to your computer and use it in GitHub Desktop.
Yammer Ruby Hacknight Golf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class<<Golf=Class.new | |
n=0;'a.reduce :* | |
(?a..?z).to_a | |
(1..a).reduce :* | |
a.map{|s|z=s[0];z==?m?"hat(#{s})":z==?d?s[0..-2]+"(bone))":"dead"+s[3..-1]} | |
(1..4).flat_map{|n|a.each_cons(n).to_a} | |
(1..a).map{|a|a%15<1?"fizzbuzz":a%3<1?"fizz":a%5<1?"buzz":a} | |
p=0;a.slice_before{|n|t=p+1<n;p=n;t}.map{|n|z="#{n[0]}";n.size>1?z+?-+"#{n[-1]}":z} | |
i,j=0,1;(1..a).map{i=j+j=i} | |
a.split.map{|s|s.size>10?s[0,4]+?.*3+s[-3,3]:s}.join" "' | |
.split(?\n).map{|m|n+=1;eval "def hole#{n} a=0 | |
#{m} | |
end"} | |
end |
474
464
462
@robmiller you can save 5 characters on line 10 by removing (" ")
since that's the default :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
476