d1 + d2/2

This commit is contained in:
Debucquoy Anthony 2023-06-16 19:21:56 +02:00
commit b4c1879c1b
Signed by: tonitch
GPG Key ID: A78D6421F083D42E
4 changed files with 1030 additions and 0 deletions

1
2015/d1/input Normal file

File diff suppressed because one or more lines are too long

14
2015/d1/main.py Normal file
View File

@ -0,0 +1,14 @@
count = 0
move = 0
with open("./input", "r") as f:
for c in f.read():
move += 1
if c == '(':
count = count + 1
elif c == ')':
count = count - 1
if count == -1:
break
print(count)
print(move)

1000
2015/d2/input Normal file

File diff suppressed because it is too large Load Diff

15
2015/d2/main.py Normal file
View File

@ -0,0 +1,15 @@
import re
def get_dimentions(inp: str) -> tuple:
result = re.match("(\d+)x(\d+)x(\d+)",inp)
return tuple(map(int, result.groups()))
def get_wrap(inp: tuple) -> int:
return 2 * inp[0] * inp[1] + 2 * inp[1] * inp[2] + 2 * inp[2] * inp[0] + min(inp[0] * inp[1], inp[1] * inp[2], inp[2] * inp[0])
with open("input", "r") as f:
presents = map(get_dimentions, map(str.strip, f.readlines()))
wrap_for_each = map(get_wrap, presents)
print(sum(wrap_for_each))
# TODO: Missing part two