about | help | code help+videos | done | prefs |
Write a method that accepts some integers and a string parameter called moves. The integers startPointX, startPointY, endPointX, and endPointY indicate the cartesian coordinates at lattice points (meaning only integer x and y values) of the point you will start at and the goal where you are trying to end. The string moves will contain any number of moves in the form U, D, L, or R which indicates up, down, left, or right. Each move has a length of 1, so moving up from (5,1) would put you at (5,2). The string called moves lists all the possible moves you could make. You do not have to use all of the moves, and you can use moves in any order. So the moves string "UR" could result in any of the following: no moves at all, up only, right only, up then right, or right then up. Your goal is to return true if there is some possible ordering using any number of moves selected from the moves string that will take you from the startPoint to the endPoint. Return false if no such path is possible. Note that one possible solution to this problem involves backtrack recursion. In fact, Admiral Ackbar tried to solve it that way. However, there are many other possible solutions and I am NOT requiring a recursive solution!!! pathExistsHL_Dec2011(8, 3, 9, 2, "") → false pathExistsHL_Dec2011(5, 6, 5, 6, "") → true pathExistsHL_Dec2011(124, 800, 123, 799, "LD") → true ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 480
Copyright Nick Parlante 2017 - privacy