Last active
October 29, 2021 10:17
-
-
Save sai-sondarkar/8e819ec8967f1ac98955bc0ea1309324 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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?
Upwards is positive you want to increment the value
…On Wed, Jun 3, 2020 at 1:51 PM AbhijeetSMankani ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Upwards is positive or negative, as in if U is received, then we increment
the 2nd value or decrement it?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/8e819ec8967f1ac98955bc0ea1309324#gistcomment-3327889>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AM6OBF5SJ577MNMHSW6HZ4TRUYB2PANCNFSM4LTH5TZA>
.
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sir, please explain this question