Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

So I am completely stuck on how to get a program to show all the possible combin

ID: 3544269 • Letter: S

Question

So I am completely stuck on how to get a program to show all the possible combinations of the problem I have been given:


A robot can only take 1, 2, and 3 meter steps. You have been assigned a small portion of the algorithm that helps the robot determine how to get from point A to point B. Your portion is to write a function that determines all the ways the robot can walk n meters. Print the result to the command window similar to the example below.


For example: If the robot needs to walk 5 meters, the ways it could do this are


#Steps   1m Steps    2m Steps    3m Steps

5                   5                   0                 0

4                   3                   1                 0

3                   2                   0                 1

3                   1                   2                 0

2                   0                    1                1


Our intructor gave us a hint and said that we will want to use a nested for loop. Can anyone point me in the right direction as to how I can go about getting the progam to show all the possible steps the robot can take? Any help is greatly appreciated! Thanks!

Explanation / Answer

For how many meters should you write a program?


You cqn create a loop where n1 is total number of 1m steps,n2 steps of 2m,n3 steps of 3m, then sum them up..If it is 5m then increase a variable by 1..

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote