please wait
read the str parameter being passed, which will represent the movements made in a 5x5 grid of cells starting from the top left position. The characters in the input string will be entirely composed of: r, l, u, d, ?. Each of the characters stand for the direction to take within the grid, for example: r = right, l = left, u = up, d = down. Your goal is to determine what characters the question marks should be in order for a path to be created to go from the top left of the grid all the way to the bottom right without touching previously traveled on cells in the grid. |
For example: if str is "r?d?drdd" then your program should output the final correct string that will allow a path to be formed from the top left of a 5x5 grid to the bottom right. For this input, your program should therefore return the string rrdrdrdd. There will only ever be one correct path and there will always be at least one question mark within the input string. |
So what is '5x5 grid of cells'? This is a two-dimensional array. What you give me is "r?d?drdd", which is technically an one-dimensional array. |
Never design alone if you can avoid it! Don't start coding before you have tried out your ideas by explaining them to someone. ... When you get stuck implementing a program, look up from the keyboard. Think about the problem itself rather than your incomplete solution. Talk with someone: explain what you want to do and why it doesn't work. It's amazing how often you find the solution just by carefully explaining the problem to someone. Don't debug (find program errors) alone if you don't have to. - Stroustrup in 'Programming: Principles and Practice using C++' |
Did you solve it in an efficient way? |