Skip to content

Commit 7e44ea7

Browse files
committed
40-compute-robot-distance
1 parent 8a2ca9e commit 7e44ea7

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import math
22
pos = [0,0]
33
while True:
4-
s = input()
4+
s = input("")
55
if not s:
66
break
77
movement = s.split(" ")

0 commit comments

Comments
 (0)