feat: Redo of the AoC repo starting over with 2015 and keeping up with

2025 (completed day 2 so far)
This commit is contained in:
2025-12-02 07:55:08 -06:00
commit c936d7d573
29 changed files with 668 additions and 0 deletions

Binary file not shown.

38
15/2/main.py Normal file
View File

@@ -0,0 +1,38 @@
'''AoC day 2'''
def get_surface_area(l: int, w: int, h: int) -> int:
'''Take the dimensions of the box and return its surface area
Keyword args:
l (int) - Length
w (int) - Width
h (int) - Height
'''
return 2*l*w + 2*w*h + 2*h*l
def get_slack_amount(l: int, w: int, h: int) -> int:
'''Take dimensions and return the value of the smallest'''
return min([l*w, w*h, h*l])
def get_ribbon_amount(l: int, w: int, h: int) -> int:
return min([2*h + 2*w, 2*l + 2*w, 2*h + 2*l]) + (l*w*h)
def main():
'''Entrypoint'''
# Surface area for wrapping paper
with open('input.txt', encoding='utf-8') as fh:
sum = 0
r_sum = 0
for line in fh:
l, w, h = [int(x) for x in line.split('x')]
# print(f'{l} {w} {h}')
sum += get_surface_area(l, w, h)
sum += get_slack_amount(l, w, h)
r_sum += get_ribbon_amount(l, w, h)
print(f'Part 1, sum of wrapping paper: {sum}')
print(f'Part 2, sum of ribbon: {r_sum}')
if __name__ == "__main__":
main()

27
15/2/test_day2.py Normal file
View File

@@ -0,0 +1,27 @@
import pytest
from main import get_slack_amount, get_surface_area, get_ribbon_amount
@pytest.mark.parametrize('l, w, h, expected',
[
(2, 3, 4, 52),
(1, 1, 10, 42)
])
def test_surface_area(l, w, h, expected):
assert get_surface_area(l, w, h) == expected
@pytest.mark.parametrize('l, w, h, expected',
[
(2, 3, 4, 6),
(1, 1, 10, 1)
])
def test_slack_amount(l, w, h, expected):
assert get_slack_amount(l, w, h) == expected
@pytest.mark.parametrize('l, w, h, expected',
[
(2, 3, 4, 34),
(1, 1, 10, 14)
])
def test_ribbon_amount(l, w, h, expected):
assert get_ribbon_amount(l, w, h) == expected