Initial commit
This commit is contained in:
commit
b1394d905a
18 changed files with 6496 additions and 0 deletions
19
day6/1.py
Normal file
19
day6/1.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
def mult(a,b):
|
||||
return a*b
|
||||
|
||||
def add(a,b):
|
||||
return a+b
|
||||
|
||||
with open(r'day6/input.txt', 'r') as input:
|
||||
lines = list(map(lambda x: x.split(), input.read().split('\n')[:-1]))
|
||||
|
||||
sum = 0
|
||||
|
||||
for i in range(len(lines[0])):
|
||||
op = add if lines[-1][i] == '+' else mult
|
||||
res = int(lines[0][i])
|
||||
for j in range(1,len(lines)-1):
|
||||
res = op(res,int(lines[j][i]))
|
||||
sum += res
|
||||
|
||||
print(sum)
|
||||
Loading…
Add table
Add a link
Reference in a new issue