d1 + d2/2
This commit is contained in:
commit
b4c1879c1b
1
2015/d1/input
Normal file
1
2015/d1/input
Normal file
File diff suppressed because one or more lines are too long
14
2015/d1/main.py
Normal file
14
2015/d1/main.py
Normal 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
1000
2015/d2/input
Normal file
File diff suppressed because it is too large
Load Diff
15
2015/d2/main.py
Normal file
15
2015/d2/main.py
Normal 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
|
Loading…
Reference in New Issue
Block a user