Created
May 26, 2015 15:01
-
-
Save tudorpavel/3dd605b2adeeab353ff3 to your computer and use it in GitHub Desktop.
Brute-force all solutions for http://img-9gag-fun.9cache.com/photo/aWW3M06_700b.jpg.
This file contains 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
def calc(arr) | |
arr[0] + (13.0 * arr[1] / arr[2]) + arr[3] + (12 * arr[4]) - arr[5] + (arr[6].to_f * arr[7] / arr[8]) | |
end | |
def solutions | |
[1,2,3,4,5,6,7,8,9].permutation.to_a.keep_if { |p| calc(p) == 87.0 } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment