Created
December 13, 2012 19:06
-
-
Save JoshuaJWilborn/4278808 to your computer and use it in GitHub Desktop.
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
move_array = [] | |
20.times { move_array << 'r' } | |
20.times { move_array << 'd' } | |
puts move_array.combination(20).to_a | |
class Array | |
def solutions | |
x=0 | |
y=0 | |
temp=self | |
until temp.empty? | |
current=temp.pop | |
if current == r | |
x+=1 | |
elsif current == d | |
y-+1 | |
end | |
end | |
if x == 20 && y == -20 | |
true | |
else | |
false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment