blob: 2a1e6e7884110a70f7ad250344bd21cc15f62e25 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#!/usr/bin/env python3
with open('MAP.INP') as fi, open('MAP.OUT', 'w') as fo:
x = y = 0
for i in fi.read().rstrip():
if i == 'E':
x -= 1
elif i == 'W':
x += 1
elif i == 'N':
y -= 1
else:
y += 1
fo.write(('E' if x > 0 else 'W') * abs(x)
+ ('N' if y > 0 else 'S') * abs(y) + '\n')
|