A robot can only take steps of 1 meter, 2 meters, and 3 meters. Design and implement
Fantastic news! We've Found the answer you've been seeking!
Question:
A robot can only take steps of 1 meter, 2 meters, and 3 meters.
Design and implement an algorithm to output all the different ways the robot can walk n meters.
Note, the order of steps must be taken into account, smaller steps must be taken first.
For example, {1, 1, 3} would be a legal solution for n = 5 but {1, 3, 1} would not because the robot can take a step of 1 meter after taking a step of 3 meters.
Your code must print all solutions for each value of n when executed.
Test Cases n = 1, 2, 3, 4, 5
Related Book For
Posted Date: