mirror of
https://github.com/sstent/Advent2021.git
synced 2026-01-28 18:11:37 +00:00
first
This commit is contained in:
41
Day1_2/main.py
Normal file
41
Day1_2/main.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from aocd import get_data
|
||||
from aocd import submit
|
||||
input_data = get_data(day=1, year=2021)
|
||||
|
||||
|
||||
|
||||
test_data = """199
|
||||
200
|
||||
208
|
||||
210
|
||||
200
|
||||
207
|
||||
240
|
||||
269
|
||||
260
|
||||
263"""
|
||||
|
||||
lines = input_data.split("\n")
|
||||
# lines = test_data.split("\n")
|
||||
|
||||
|
||||
count = 0
|
||||
window_list = []
|
||||
for index, value in enumerate(lines):
|
||||
if index <= len(lines) - 3:
|
||||
window = int(lines[index]) + int(lines[index + 1]) + int(lines[index + 2])
|
||||
window_list.append(window)
|
||||
|
||||
|
||||
for index, value in enumerate(window_list):
|
||||
if index != 0:
|
||||
if int(value) > int(window_list[index - 1]):
|
||||
print(str(index)+ ": " + str(value) + " + "+ str(window_list[index - 1]))
|
||||
# print("1")
|
||||
count += 1
|
||||
|
||||
print("Input length:" + str(len(lines)))
|
||||
print(count)
|
||||
print(window_list)
|
||||
|
||||
submit(count)
|
||||
Reference in New Issue
Block a user