Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fill(s, l):
- for i in range(min([s, l], key=lambda x: x[0])[0], max([s, l], key=lambda x: x[0])[0] + 1):
- for j in range(min([s, l], key=lambda x: x[1])[1], max([s, l], key=lambda x: x[1])[1] + 1):
- v[i, j] = 1 if (i, j) in v and (i != l[0] or j != l[1]) else 0
- if v[i, j] == 1:
- return i, j
- return -1, -1
- s = [0, 0]; d = 0; v = {}; f = []
- move = map(lambda x: x if x[0] != " " else x[1:], open("input1").readline().split(","))
- for m in move:
- l = s[:];
- d = (d + (1 if m[0] == "R" else -1)) % 4
- s[d % 2] += (1 if d < 2 else -1) * int(m[1:])
- f.append(list(map(lambda x: reduce(lambda a, c: abs(a) + abs(c), x) if tuple(x) != (-1, -1) else -1, [fill(s, l)]))[0])
- print(str(reduce(lambda a, c: c if c != -1 else a, list(reversed(f)))) + " " + str(reduce(lambda a, c: abs(a) + abs(c), s)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement