From 6a0325b3ab8e4680de8b4786ada721a1e671157c Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 9 Dec 2016 18:42:45 +0100 Subject: Initial --- 2a.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 2a.py (limited to '2a.py') diff --git a/2a.py b/2a.py new file mode 100755 index 0000000..d01793f --- /dev/null +++ b/2a.py @@ -0,0 +1,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() -- cgit v1.2.3-54-g00ecf