-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path10a_aoc.py
31 lines (28 loc) · 825 Bytes
/
10a_aoc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
M = 256
class List():
def __init__(self):
self.l = range(M)
self.currentPos = 0
self.skipSize = 0
def reverse(self, length):
elms = [self.l[(self.currentPos+x)%M] for x in range(length)]
elms.reverse()
for x in range(length):
self.l[(self.currentPos+x)%M] = elms[x]
self.currentPos += (self.skipSize + length)
self.currentPos %= M
self.skipSize += 1
def __repr__(self):
s = "["
for x in range(M):
if x == self.currentPos:
s+=" ("+str(self.l[x])+") "
else:
s+=" "+str(self.l[x])+" "
s += "] (%d)"%self.skipSize
return s #return the value
lengths = map(int, raw_input().split(','))
L = List()
for l in lengths:
L.reverse(l)
print L