Skip to content

Instantly share code, notes, and snippets.

@nilsding
Last active May 8, 2019 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilsding/0dc88366f1380791405614563094e36b to your computer and use it in GitHub Desktop.
Save nilsding/0dc88366f1380791405614563094e36b to your computer and use it in GitHub Desktop.
# 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