AdventOfCode/Day01/day01.py
2021-12-13 18:13:06 +01:00

38 lines
848 B
Python
Executable File

#!/usr/bin/env python3
def day01Part1():
with open("data/input.txt","r") as f:
myInput=f.read().splitlines()
counter=0
previous=int(myInput[0])
for item in myInput[1:]:
if int(item) > int(previous):
# print(previous, item, 'Increased')
counter=counter+1
if int(item) < int(previous):
# print(previous, item,'decreased')
pass
previous=item
print('Part1: Number of increases: ', counter)
def day01Part2():
with open("data/test.txt","r") as f:
myInput=f.read().splitlines()
counter=0
previous=int(myInput[0])
print(type(previous))
for i in range(len(myInput)-1):
if i < len(myInput-2):
sum=myInput[i]+myInput[i+1]+myInput[i+2]
print(sum)
previous=int(myInput[0])
# if the item before is the same as the one after than it will say no change
if __name__=='__main__':
day01Part1()
day01Part2()