The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 399 Weeks Ago, 1 Day Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
There is s a square maze consisting of N rows and N columns divided into unit cells. The rows are numbered from the top to the bottom starting from 1, and the columns are numbered from the left to the right also starting from 1.
Â
You have a robot which you have to operate. Initially the robot is located in the upper-left corner of the maze (i.e. at the cell (1, 1)). In a single move you can move the robot in any one of four basic directions: left, right, up or down.
Â
Some cells of the maze are forbidden. It is known that there are no two forbidden cells that share an edge or a corner. The cell (1, 1) is not forbidden.
Â
You have to construct a sequence of moves of the robot satisfying the following conditions.
Â
Â
You are interested in finding any valid sequence of moves such that there are no more than three consecutive moves that moved the robot in the same direction eg. 'DDDD' is invalid sequence of moves while 'D' and 'DDD' is valid. Also total number of moves should not be more than N * (N + 7). Please find any such sequence.
Â
Â
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
Â
The first line of each test case contains the single integer N.
Â
In the next N lines, each line contains N characters representing the rows of maze. The characters can be one of the following ones:
Â
Â
Â
For each test case, output a single line containing the answer to the corresponding test case. The answer should be a string of characters 'L', 'R', 'U' and 'D', representing left, right, up and down moves, respectively. The answer for each test case should not contain more than N*(N+7) moves.
Â
Â
Â
Input: 2 2 .. .# 3 ... #.. ..# Output: DUR RRDLDL
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll