Created
May 10, 2013 19:10
-
-
Save gary-rafferty/5556677 to your computer and use it in GitHub Desktop.
zerosum
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 zerosum(arr,size=4) | |
arr.permutation(size).to_a.each do |a| | |
if a.inject(:+) == 0 | |
p a.inspect | |
break | |
end | |
end | |
end | |
zerosum([2,3,5,6,7,8,9,1,2,3,-1,-11,44,-1,0,1,1],5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment