Your trip is amongst the mighty mountains of Canada and whilst planning your trip, you come across a situation -
Due to the terrain of the mountains, you are confined to move forward in diagonal directions (North-East and South-East). And to avoid the risk of falling off (below x-axis is the death valley) or an accident, you have to take one step at a time.
The geographics of the track are similar to the previous problem, in a form of a 2-D rectangular lattice spanning from (0,0) to (2*m,n).
In order to plan the route of your trip, it is necessary to visualize all the routes. To fulfill the necessary requirement of visualizing the routes, you, now, have to count the paths with exactly n number of peaks (local maxima); from your initial position (although relative, consider it to be 0,0) to the end point (2*m,0).
You being an avid mathematics aficionado, are compelled to solve the problem.
Given two natural numbers, m and n (<=m), find the number of routes with the mentioned restriction, to prepare a strategy.
Example: All possible pathways for m=3
For n=2, output should be 3 > as there are 3 possible routes with exactly 2 peaks.
Solution Stats
Solution Comments
Show comments
Loading...
Problem Recent Solvers6
Suggested Problems
-
Sort numbers by outside digits
164 Solvers
-
Rotate input square matrix 90 degrees CCW without rot90
699 Solvers
-
367 Solvers
-
Circular Primes (based on Project Euler, problem 35)
658 Solvers
-
Remove entire row and column in the matrix containing the input values
576 Solvers
More from this Author44
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!