[Python/2015] Move solutions into .py files
This commit is contained in:
parent
8c2be5fb77
commit
94dd3ae399
52 changed files with 996 additions and 3314 deletions
18
Python/2015/03.py
Normal file
18
Python/2015/03.py
Normal file
|
@ -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…
Add table
Add a link
Reference in a new issue