Skip to content

Instantly share code, notes, and snippets.

@nilsding

nilsding/cursed5.rb

Last active May 8, 2019
Embed
What would you like to do?
# Cursed ways to return 5 without using 0123456789+-*/
[[],[],[],[],[]].size # => 5
Array(?;..??).size # => 5
module Solution3
def self.method_missing(name)
return name.size if name =~ %r{^.....$} # => 0
super
end # => :method_missing
end # => :method_missing
Solution3.honk! # => 5
proc{def a;raise ??;rescue;yield;end;begin;eval"proc#{eval"'aaaaa'.gsub(%r{.},\"{\\\\#{?}.to_i}}\").chars.sort{|c|c==?}???.to_i.succ: ??.to_i}.join"}[]";rescue=>e;end;d=?d.to_i;d=d.succ while e=e.cause;d}[] # => 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment