logo Practice-It logo

solve

Language/Type: Java recursion
Author: Marty Stepp (on 2020/11/05)

Write a recursive method called solve that takes integers x and y as parameters and that prints all solutions for traveling from (0, 0) to (x, y) using one of three moves:

        North (abbreviation N):      move up 1 (increase y)
        East (abbreviation E):       move right 1 (increase x)
        NorthEast (abbreviation NE): move up 1 and right 1 (increase both)

For example, if passed the values 1 and 2, it should print the following solutions:

        solutions:
        moves: N N E
        moves: N NE
        moves: N E N
        moves: NE N
        moves: E N N
Type your solution here:


This is a method problem. Write a Java method as described. Do not write a complete program or class; just the method(s) above.

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.