Solving Hari Prasad Misra's Staircase Problem with Max 2 Steps

  • Thread starter s_chaursia
  • Start date
But, you must try to write a program; you cannot just ask for one. In summary, Hari Prasad Misra has trouble reaching his classroom on time because he has to climb stairs. To help him, he wants to create a program that calculates the number of ways he can climb the stairs, with a maximum of 2 stairs at a time. The program should take the number of stairs as an input and print the number of possible ways. The example given is 3 stairs with 3 possible ways. The program should be able to handle 0 to 100 stairs.
  • #1
s_chaursia
3
0
Hari Prasad Misra Of IT Branch has to climb up stairs daily to reach to his class room. But
daily he doesn’t manage to reach in the class room on time.
So, he decided to form a program which tells him in how many ways he can climb upstairs
and reach to his class room.
But he can climb Maximum of 2 Stairs at one time.
You need to write a program for him in order to calculate the NO. of possible ways to reach
when he can climb one step, two steps, or one or two steps both simultaneously to reach up
stairs.
Example:
Here No of stairs are =3
So the possible ways are 3 stairs
First way 1,1,1(steps)
Second way 1,2(steps)
Third Way 2,1(steps)
So the no of ways are= 3
INPUT You have to take No. of staircases as an input. Where No. (0<=N<=100).
OUTPUT You have to print the No. of Possible ways.
Sample Input:
6
4
3
Sample Output
13
5
3
 
Physics news on Phys.org
  • #2
No, believe it or not, I do not have to write a program for him! Perhaps you do and, if you get started on it, someone here might make suggestions how to improve your program.
 

What is Hari Prasad Misra's Staircase Problem?

Hari Prasad Misra's Staircase Problem is a mathematical puzzle that involves finding the number of ways to climb a staircase with n steps by taking either 1 or 2 steps at a time.

What is the significance of solving this problem with Max 2 Steps?

The constraint of taking a maximum of 2 steps at a time adds an additional layer of complexity to the problem, making it more challenging and interesting to solve.

How can this problem be applied in real life?

Solving Hari Prasad Misra's Staircase Problem with Max 2 Steps can have real-life applications in various fields such as computer science, game theory, and optimization problems.

What is the most efficient way to solve this problem?

The most efficient way to solve this problem is by using dynamic programming, which involves breaking down the problem into smaller subproblems and storing the solutions to these subproblems to avoid repeating calculations.

Are there any other variations of this problem?

Yes, there are other variations of this problem, such as finding the number of ways to climb a staircase with n steps by taking either 1, 2, or 3 steps at a time. These variations can also be solved using dynamic programming.

Similar threads

  • General Discussion
4
Replies
111
Views
6K
Replies
23
Views
6K
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
6K
  • Beyond the Standard Models
Replies
11
Views
2K
Replies
42
Views
6K
  • General Discussion
Replies
9
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
Replies
4
Views
3K
  • General Discussion
Replies
2
Views
3K
Back
Top