blob: d01793feb23d17e18fba407c6b12f3730ec44332 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#!/usr/bin/env python3
import sys
lines=sys.stdin.read().split("\n")[:-1]
p=5
for l in lines:
for c in l:
if c=="U": p=p-3 if p>=4 else p
elif c=="R": p=p+1 if p%3!=0 else p
elif c=="D": p=p+3 if p<=6 else p
elif c=="L": p=p-1 if p%3!=1 else p
else: assert False
print(p,end="")
print()
|