Day 6: Part 1 a
This commit is contained in:
24
day6/main.py
Normal file
24
day6/main.py
Normal file
@@ -0,0 +1,24 @@
|
||||
with open("day6/input.txt") as file:
|
||||
lines = file.readlines()
|
||||
|
||||
|
||||
lines = [line.strip("\n").split() for line in lines]
|
||||
for i in range(4):
|
||||
lines[i] = [int(number) for number in lines[i]]
|
||||
|
||||
linesLen = len(lines)
|
||||
lineLen = len(lines[0])
|
||||
|
||||
grandTotal = 0
|
||||
for i in range(lineLen):
|
||||
if(lines[4][i] == "*"):
|
||||
grandTotal = grandTotal + (lines[0][i]*lines[1][i]*lines[2][i]*lines[3][i])
|
||||
elif(lines[4][i] == "+"):
|
||||
grandTotal = grandTotal + (lines[0][i]+lines[1][i]+lines[2][i]+lines[3][i])
|
||||
else:
|
||||
print("ohoh ein Fehler")
|
||||
|
||||
newGrandTotal = 0
|
||||
# Part 2
|
||||
|
||||
print(f"Part 1: {grandTotal}\n\rPart 2: {newGrandTotal}")
|
||||
Reference in New Issue
Block a user