Solve 2017 day 1 because I have to make Beeminder progress. Lol.
This commit is contained in:
14
2017/d1.py
Normal file
14
2017/d1.py
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
data = open(0).read().strip()
|
||||
|
||||
s = 0
|
||||
for i in range(len(data)):
|
||||
if data[i] == data[(i + 1) % len(data)]:
|
||||
s += int(data[i])
|
||||
print(s)
|
||||
|
||||
s = 0
|
||||
for i in range(len(data)):
|
||||
if data[i] == data[(i + len(data) // 2) % len(data)]:
|
||||
s += int(data[i])
|
||||
print(s)
|
||||
Reference in New Issue
Block a user