diff options
author | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-06-22 15:13:21 +0700 |
---|---|---|
committer | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-06-22 15:13:21 +0700 |
commit | f38658aa390402fd3ef8b6f00f3235eb41009297 (patch) | |
tree | 2d72bd696bcfd0c2c9fe179505162687b91c8f28 /others/153x/053.py | |
parent | 4ac65940e064c5b587699549a0c7277d2dd733a8 (diff) | |
download | cp-f38658aa390402fd3ef8b6f00f3235eb41009297.tar.gz |
Update others/153x
Diffstat (limited to 'others/153x/053.py')
-rwxr-xr-x | others/153x/053.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/others/153x/053.py b/others/153x/053.py new file mode 100755 index 0000000..2a1e6e7 --- /dev/null +++ b/others/153x/053.py @@ -0,0 +1,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') |