summaryrefslogtreecommitdiff
path: root/2b.py
diff options
context:
space:
mode:
Diffstat (limited to '2b.py')
-rwxr-xr-x2b.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/2b.py b/2b.py
new file mode 100755
index 0000000..2fe50f3
--- /dev/null
+++ b/2b.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+import sys
+
+pad=[
+ -1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1, 1,-1,-1,-1,
+ -1,-1, 2, 3, 4,-1,-1,
+ -1, 5, 6, 7, 8, 9,-1,
+ -1,-1,10,11,12,-1,-1,
+ -1,-1,-1,13,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1]
+
+H="0123456789ABCD"
+
+W=7
+
+lines=sys.stdin.read().split("\n")[:-1]
+p=22
+for l in lines:
+ for c in l:
+ if c=="U": p=p-W if pad[p-W]!=-1 else p
+ elif c=="R": p=p+1 if pad[p+1]!=-1 else p
+ elif c=="D": p=p+W if pad[p+W]!=-1 else p
+ elif c=="L": p=p-1 if pad[p-1]!=-1 else p
+ else: assert False
+ print(H[pad[p]],end="")
+print()