finished day 01
This commit is contained in:
parent
90d722def0
commit
44404a3ae8
24
Day01/day01.py
Normal file → Executable file
24
Day01/day01.py
Normal file → Executable file
@ -19,13 +19,25 @@ def day01Part1():
|
||||
def day01Part2():
|
||||
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('no change')
|
||||
# if the item before is the same as the one after than it will say no change
|
||||
counter=0
|
||||
previous=999999
|
||||
|
||||
i=0
|
||||
for item in myInput:
|
||||
if i < len(myInput)-2:
|
||||
total=int(myInput[i])+int(myInput[i+1])+int(myInput[i+2])
|
||||
if previous < total:
|
||||
print(previous, total, 'Increased')
|
||||
counter=counter+1
|
||||
else:
|
||||
print(previous, total,'decreased')
|
||||
i=i+1
|
||||
previous=total
|
||||
|
||||
print('Part2: Number of increases: :', counter)
|
||||
|
||||
# if the item before is the same as the one after curent it will say no change --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh than it will say no change
|
||||
# A comment
|
||||
if __name__=='__main__':
|
||||
day01Part1()
|
||||
day01Part2()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user