Created
June 19, 2015 19:49
-
-
Save flou/0d4becb15226bf078f5c to your computer and use it in GitHub Desktop.
Quick and dirty solution for this puzzle http://gizmodo.com/can-you-solve-this-vietnamese-math-puzzle-for-8-year-ol-1705734738
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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