Compare commits
No commits in common. "b55fdbe333517c7578d24672f4d1a00b2fffdcae" and "44404a3ae85879712735b2fd429fc02d43b8d97d" have entirely different histories.
b55fdbe333
...
44404a3ae8
@ -17,20 +17,27 @@ def day01Part1():
|
|||||||
print('Part1: Number of increases: ', counter)
|
print('Part1: Number of increases: ', counter)
|
||||||
|
|
||||||
def day01Part2():
|
def day01Part2():
|
||||||
with open("data/test.txt","r") as f:
|
with open("data/input.txt","r") as f:
|
||||||
myInput=f.read().splitlines()
|
myInput=f.read().splitlines()
|
||||||
counter=0
|
counter=0
|
||||||
previous=int(myInput[0])
|
previous=999999
|
||||||
print(type(previous))
|
|
||||||
for i in range(len(myInput)-1):
|
i=0
|
||||||
if i < len(myInput-2):
|
for item in myInput:
|
||||||
sum=myInput[i]+myInput[i+1]+myInput[i+2]
|
if i < len(myInput)-2:
|
||||||
print(sum)
|
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
|
||||||
|
|
||||||
previous=int(myInput[0])
|
print('Part2: Number of increases: :', counter)
|
||||||
|
|
||||||
# if the item before is the same as the one after than it will say no change
|
# 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__':
|
if __name__=='__main__':
|
||||||
day01Part1()
|
day01Part1()
|
||||||
day01Part2()
|
day01Part2()
|
||||||
|
|||||||
1000
Day02/data/input.txt
1000
Day02/data/input.txt
File diff suppressed because it is too large
Load Diff
@ -1,6 +0,0 @@
|
|||||||
forward 5
|
|
||||||
down 5
|
|
||||||
forward 8
|
|
||||||
up 3
|
|
||||||
down 8
|
|
||||||
forward 2
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
from pprint import pprint
|
|
||||||
|
|
||||||
def day02Part1():
|
|
||||||
|
|
||||||
with open("data/input.txt","r") as f:
|
|
||||||
myInput=f.read().splitlines()
|
|
||||||
|
|
||||||
newResult=convertData(myInput)
|
|
||||||
pprint(newResult)
|
|
||||||
horizontal=0
|
|
||||||
depth=0
|
|
||||||
for item in newResult:
|
|
||||||
if item[0]=="forward":
|
|
||||||
horizontal=horizontal+item[1]
|
|
||||||
if item[0]=="down":
|
|
||||||
depth=depth+item[1]
|
|
||||||
if item[0]=='up':
|
|
||||||
depth=depth-item[1]
|
|
||||||
|
|
||||||
print('Horizontal: ', horizontal, 'depth: ', depth, 'result: ', depth*horizontal)
|
|
||||||
|
|
||||||
|
|
||||||
def convertData(alist):
|
|
||||||
result=[]
|
|
||||||
for item in alist:
|
|
||||||
s=item.split()
|
|
||||||
s[1]=int(s[1])
|
|
||||||
result.append(s)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
day02Part1()
|
|
||||||
Loading…
x
Reference in New Issue
Block a user