Skip to content

Instantly share code, notes, and snippets.

@flou
Created June 19, 2015 19:49
Show Gist options
  • Save flou/0d4becb15226bf078f5c to your computer and use it in GitHub Desktop.
Save flou/0d4becb15226bf078f5c to your computer and use it in GitHub Desktop.
formula = "%d.0 + 13 * %d.0 / %d.0 + %d.0 + 12 * %d.0 - %d.0 - 11 + %d.0 * %d.0 / %d.0 - 10"
combinations = (1..9).to_a.permutation.map(&:join)
combinations.each do |combination|
expr = format(formula, *combination.split(''))
result = eval(expr)
puts expr.gsub(/\.0/, '') if result == 66.0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment