| about | help | code help+videos | done | prefs |
num_paths
You are in a grid of city blocks, and you want to know how many different paths there are between your current corner and a destination corner (without taking any steps in the wrong direction). The current corner is given by two non-negative integers x, y indicating the number of blocks east and north you are, respectively, of the destination (in other words the desitination is at 0,0). For example, if you start at (1, 1) then there are 2 paths: you could go west one block and then south, or south one block and then west. If you start at (2, 1) there are three paths: [west, west, south], [west, south, west], and [south, west, west]. Write num_paths(x, y) that returns the number of paths from location x,y to the destination 0,0. (You don't need to say what the individual paths are, just count them.) num_paths(1, 1) → 2 num_paths(5, 0) → 1 num_paths(0, 10) → 1 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 310 Post-solution available
Copyright Nick Parlante 2017 - privacy