-
-
Save sai-sondarkar/8e819ec8967f1ac98955bc0ea1309324 to your computer and use it in GitHub Desktop.
Ankit is in maze. The command center sent him a string which decodes to come out from the maze. | |
He is initially at (0, 0). | |
String contains L, R, U, D denoting left, right, up and down. | |
In each command he will traverse 1 unit distance in the respective direction. | |
For example if he is at (2, 0) and the command is L he will go to (1, 0). | |
You guys just need to make the flow of the logic which updates the position after taking input from u L, R, U, D |
Please explain what needs to be done in the problem statement
Sir, Please explain what to do in this problem.
Sir, please explain this question
Sir,I can't understand this please explain
sir if i am not wrong then we can solve keeping mind the co-ordinate axes
but if we use co ordinate axis , we will end at the initial point
Sir i didn't understand what has to be done here, could you please elaborate it? Thank you
Upwards is positive or negative, as in if U is received, then we increment the 2nd value or decrement it?
sir,can u explain the problem statement..plzz
can't get the statement
As per what I understood from the problem statement, this should be the answer:
def getCoordinates(arr) :
x = 0
y = 0
for i in arr :
if (i == 'L') :
x = x-1
elif (i == 'R') :
x = x+1
elif (i == 'U') :
y = y+1
elif (i == 'D') :
y = y-1
return [x,y]
print(getCoordinates(['L', 'U', 'U', 'D', 'U', 'U', 'R', 'D' ]))
Based on those inputs the output should be [0, 2]
Please tell me if that's an incorrect solution.
Sir please illustrate the question