Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f = open("input.txt").read().strip().split("\n")
- inp = f[0]
- cups = list(map(int, list(inp)))
- mi = min(cups)
- oldma = max(cups)
- cups = cups + [i for i in range(oldma + 1, 1000001)]
- ma = 1000000
- d = {}
- for i in range(1, len(cups)):
- d[cups[i - 1]] = cups[i]
- print(i)
- d[cups[i]] = cups[0]
- d[-1] = cups[0]
- start = -1
- for i in range(10000000):
- if i % 1000000 == 0:
- print(i)
- first = d[start]
- x = d[first]
- y = d[x]
- z = d[y]
- firstnext = d[z]
- dest = first - 1
- while(True):
- if dest < mi:
- dest = ma
- if dest not in [x,y,z,first]:
- destnext = d[dest]
- d[dest] = x
- d[z] = destnext
- break
- else:
- dest -= 1
- d[first] = firstnext
- start = first
- one = d[1]
- two = d[one]
- print(one * two)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement