Skip to content

Instantly share code, notes, and snippets.

@tudorpavel
Created May 26, 2015 15:01
Show Gist options
  • Save tudorpavel/3dd605b2adeeab353ff3 to your computer and use it in GitHub Desktop.
Save tudorpavel/3dd605b2adeeab353ff3 to your computer and use it in GitHub Desktop.
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