Skip to content

Commit

Permalink
[Python/2015] Move solutions into .py files
Browse files Browse the repository at this point in the history
  • Loading branch information
Defelo committed Oct 29, 2023
1 parent 8c2be5f commit 94dd3ae
Show file tree
Hide file tree
Showing 52 changed files with 996 additions and 3,314 deletions.
109 changes: 0 additions & 109 deletions Python/2015/01.ipynb

This file was deleted.

9 changes: 9 additions & 0 deletions Python/2015/01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from lib import *

input = read_input(2015, 1)

x = 0
cum = [(x := x + [-1, 1][c == "("]) for c in input]

print(cum[-1])
print(cum.index(-1) + 1)
114 changes: 0 additions & 114 deletions Python/2015/02.ipynb

This file was deleted.

15 changes: 15 additions & 0 deletions Python/2015/02.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from lib import *

input = read_input(2015, 2)

boxes = [sorted(map(int, line.split("x"))) for line in input.splitlines()]

total = 0
for a, b, c in boxes:
total += 2 * (a * b + a * c + b * c) + a * b
print(total)

total = 0
for a, b, c in boxes:
total += 2 * (a + b) + a * b * c
print(total)
117 changes: 0 additions & 117 deletions Python/2015/03.ipynb

This file was deleted.

18 changes: 18 additions & 0 deletions Python/2015/03.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from lib import *

input = read_input(2015, 3)


def get_houses(instructions):
houses = [(x := 0, y := 0)]
for c in instructions:
x += c == ">"
x -= c == "<"
y += c == "v"
y -= c == "^"
houses.append((x, y))
return houses


print(len(set(get_houses(input))))
print(len(set(get_houses(input[::2])) | set(get_houses(input[1::2]))))
Loading

0 comments on commit 94dd3ae

Please sign in to comment.