Skip to content

Instantly share code, notes, and snippets.

@dbushong
Forked from TheSkyIsBlottedOut/hundredsgolf.rb
Last active August 29, 2015 14:27
Show Gist options
  • Save dbushong/2f62ac340fe4724d5cfc to your computer and use it in GitHub Desktop.
Save dbushong/2f62ac340fe4724d5cfc to your computer and use it in GitHub Desktop.
#f '123456789',100
def f(d,t)(0...3**(d.size-1)).map{|c|d.chars.reduce{|s,g|o='+-'[c%3]||'';c=(c/3).floor;s+o+g}}.select{|e|e.scan(/\D?\d+/).map(&:to_i).reduce(:+)==t}end
if __FILE__ == $0
p f('123456789', 100)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment