24 lines
635 B
Python
24 lines
635 B
Python
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}") |