Skip to content

Instantly share code, notes, and snippets.

@lukebergen
Last active August 29, 2015 14:22
Show Gist options
  • Save lukebergen/8643955e2f65bda7e47b to your computer and use it in GitHub Desktop.
Save lukebergen/8643955e2f65bda7e47b to your computer and use it in GitHub Desktop.
def find_100s(digits, i=0)
if i == digits.length - 1
eval(digits) == 100 ? [digits] : []
else
[find_100s(digits[0..i] + "+" + digits[i+1..-1], i+2), find_100s(digits[0..i] + "-" + digits[i+1..-1], i+2), find_100s(digits, i+1)]
end
end
puts find_100s("123456789")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment