diff options
Diffstat (limited to '2b.py')
-rwxr-xr-x | 2b.py | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -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() |