Skip to content

Instantly share code, notes, and snippets.

Created June 8, 2016 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/edcc55be663d21a989a10bf58cf6c03f to your computer and use it in GitHub Desktop.
Save anonymous/edcc55be663d21a989a10bf58cf6c03f to your computer and use it in GitHub Desktop.
#!/usr/local/bin/ruby
def runner( x, y, size, num )
=begin
if x == size && y == size
puts "Path found"
end
unless x + 1 > size
runner( x + 1, y, size )
end
unless y + 1 > size
runner( x, y + 1, size )
end
=end
if x + 1 <= size && y + 1 <= size
num + runner( x + 1, y, size, num) + runner( x, y + 1, size, num)
elsif x + 1 <= size && y + 1 > size
num + runner( x + 1, y, size, num)
elsif x + 1 > size && y + 1 <= size
num + runner( x, y + 1, size, num)
else
return 1
end
puts num
end
runner( 0 , 0, 2, 0 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment