Skip to content

Instantly share code, notes, and snippets.

@tadowns
Created April 7, 2016 14:57
Show Gist options
  • Save tadowns/6ffce6aa21b1b53be39b6ca9f2ac876b to your computer and use it in GitHub Desktop.
Save tadowns/6ffce6aa21b1b53be39b6ca9f2ac876b to your computer and use it in GitHub Desktop.
SnakeCase
class SnakePath
def initialize
@paths = Array.new()
end
def add_direction (direction, current_path, south_count, east_count)
south_count = south_count + 1 if direction == 'South'
east_count = east_count + 1 if direction == 'East'
add_direction('South', current_path + "#{direction}, ", south_count, east_count) if south_count < 10
add_direction('East', current_path + "#{direction}, ", south_count, east_count) if east_count < 10
@paths.push(current_path) if(south_count == 10 && east_count == 10)
end
def print_paths
puts @paths
puts "Damn son #{@paths.count}"
end
end
snake_path = SnakePath.new()
snake_path.add_direction('East', '', 0, 0)
snake_path.add_direction('South', '', 0, 0)
# total paths: 184756
snake_path.print_paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment