We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8a2ca9e commit 7e44ea7Copy full SHA for 7e44ea7
exercises/40-compute-robot-distance/app.py
@@ -0,0 +1,21 @@
1
+import math
2
+pos = [0,0]
3
+while True:
4
+ s = input("")
5
+ if not s:
6
+ break
7
+ movement = s.split(" ")
8
+ direction = movement[0]
9
+ steps = int(movement[1])
10
+ if direction=="UP":
11
+ pos[0]+=steps
12
+ elif direction=="DOWN":
13
+ pos[0]-=steps
14
+ elif direction=="LEFT":
15
+ pos[1]-=steps
16
+ elif direction=="RIGHT":
17
+ pos[1]+=steps
18
+ else:
19
+ pass
20
+
21
+print (int(round(math.sqrt(pos[1]**2+pos[0]**2))))
exercises/40-compute-robot-distance/solution.hide.py
@@ -1,7 +1,7 @@
import math
pos = [0,0]
while True:
- s = input()
if not s:
break
movement = s.split(" ")
0 commit comments