Skip to content

Instantly share code, notes, and snippets.

@JoshuaJWilborn
Created December 13, 2012 19:06
Show Gist options
  • Save JoshuaJWilborn/4278808 to your computer and use it in GitHub Desktop.
Save JoshuaJWilborn/4278808 to your computer and use it in GitHub Desktop.
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