Skip to content

Instantly share code, notes, and snippets.

@jbranchaud
Last active January 22, 2016 22:11
Show Gist options
  • Save jbranchaud/96f3e57895b65e011947 to your computer and use it in GitHub Desktop.
Save jbranchaud/96f3e57895b65e011947 to your computer and use it in GitHub Desktop.
NUMBER_OF_BLOCKS = 20
GRID_SIZE = NUMBER_OF_BLOCKS + 1
previous_row = Array.new(GRID_SIZE, 1)
(GRID_SIZE-1).times do |_|
previous_row =
previous_row.each_with_object([]) do |item,current_row|
current_row << item + (current_row.last || 0)
end
end
puts "# of unqiue paths: #{previous_row.last}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment