-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday2.py
36 lines (24 loc) · 815 Bytes
/
day2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# vi: set shiftwidth=4 tabstop=4 expandtab:
import datetime
import os
import int_code
top_dir = os.path.dirname(os.path.abspath(__file__)) + "/../../"
def run_tests():
int_code.run_tests_day2()
def part1(intcode):
return int_code.run_verb_noun(intcode, 12, 2)
def part2(intcode):
for verb in range(99 + 1):
for noun in range(99 + 1):
if int_code.run_verb_noun(intcode, noun, verb) == 19690720:
return 100 * noun + verb
def get_solutions():
intcode = int_code.get_intcode_from_file("../../resources/year2019_day2_input.txt")
print(part1(intcode) == 5534943)
print(part2(intcode) == 7603)
if __name__ == "__main__":
begin = datetime.datetime.now()
run_tests()
get_solutions()
end = datetime.datetime.now()
print(end - begin)