Skip to content

Instantly share code, notes, and snippets.

@fallengiants
Created August 4, 2015 18:29
Show Gist options
  • Select an option

  • Save fallengiants/4141819bc12be7ffad34 to your computer and use it in GitHub Desktop.

Select an option

Save fallengiants/4141819bc12be7ffad34 to your computer and use it in GitHub Desktop.
1.upto(3**8).each do |i|
flags = i.to_s(3).rjust(8, ?0).split(//)
math = ''
1.upto(9).map do |c|
math += c.to_s
math += case flags.shift
when ?1 then ?+
when ?2 then ?-
else ''
end
end
puts math if eval(math) == 100
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment