mirror of
https://github.com/Findus23/AdventOfCode2019.git
synced 2024-08-27 19:52:12 +02:00
finish first two days
This commit is contained in:
parent
1d7a4b95a4
commit
38f37f755c
2 changed files with 6 additions and 6 deletions
|
@ -3,7 +3,7 @@ from typing import List
|
|||
intcode = List[int]
|
||||
|
||||
|
||||
def opcode_parse(text: str) -> intcode:
|
||||
def parse_intcode(text: str) -> intcode:
|
||||
return list(map(int, text.split(",")))
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ def run_intcode(codelist: intcode) -> intcode:
|
|||
|
||||
def part1() -> int:
|
||||
with open("2/input.txt") as f:
|
||||
cl = opcode_parse(f.read())
|
||||
cl = parse_intcode(f.read())
|
||||
cl[1] = 12
|
||||
cl[2] = 2
|
||||
cl = run_intcode(cl)
|
||||
|
@ -38,7 +38,7 @@ def part1() -> int:
|
|||
|
||||
def part2() -> int:
|
||||
with open("2/input.txt") as f:
|
||||
initial_cl = opcode_parse(f.read())
|
||||
initial_cl = parse_intcode(f.read())
|
||||
|
||||
for noun in range(99):
|
||||
for verb in range(99):
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from day2 import opcode_parse, run_intcode, part1, part2
|
||||
from day2 import parse_intcode, run_intcode, part1, part2
|
||||
|
||||
|
||||
def test_opcode_parse():
|
||||
assert opcode_parse("2,2,3,45,5") == [2, 2, 3, 45, 5]
|
||||
def test_parse_intcode():
|
||||
assert parse_intcode("2,2,3,45,5") == [2, 2, 3, 45, 5]
|
||||
|
||||
|
||||
def test_run_intcode():
|
||||
|
|
Loading…
Reference in a new issue