-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path17a_aoc.py
More file actions
32 lines (30 loc) · 904 Bytes
/
17a_aoc.py
File metadata and controls
32 lines (30 loc) · 904 Bytes
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
32
class CircularBuffer():
"""Creates a circular buffer with the insert() operation
as specified in the problem"""
def __init__(self,stepsize):
self.stepsize = stepsize
self.currentPos = 0
self.maxval = 0
self.list_ = [0]
def insert(self):
self.currentPos += self.stepsize
self.currentPos %= self.maxval+1
self.maxval += 1
self.currentPos += 1
self.list_.insert(self.currentPos,self.maxval)
def __str__(self):
p = ""
for i in range(len(self.list_)):
if i != 0:
p += " "
if i != self.currentPos:
p += str(self.list_[i])
else:
p += "("+str(self.list_[i])+")"
return p
def main():
c = CircularBuffer(int(raw_input()))
for x in range(2017):
c.insert()
print c.list_[c.currentPos+1]
main()