advent-of-code/1/solution.py

21 lines
532 B
Python
Raw Normal View History

2023-12-02 02:26:37 +00:00
#!/usr/bin/env python
def get_positive_changes(values):
count = 0
for i in range(1, len(values)):
if int(values[i - 1]) < int(values[i]):
count += 1
return count
if __name__ == '__main__':
f = open("input", "r")
values = f.readlines()
print('1. solution:', get_positive_changes(values))
new_values = []
for i in range(2, len(values)):
new_values.append(int(values[i]) + int(values[i-1]) + int(values[i-2]))
print('2. solution:', get_positive_changes(new_values))