Exemple #1
0
import os
import mod2

fileDir = os.path.dirname(os.path.realpath(__file__))
probleminput = os.path.join(fileDir, 'input.txt')


with open(probleminput) as f:
    input_numbers = [int(x) for x in f.read().split(',')]

computer = mod2.ShipComputer(input_numbers)

answer1 = computer.runprogram(12,2)[0]

print(f"The answer to day 2 part 1 is: {answer1}")

answer2 = computer.getnounverb(19690720, 99)

print(f"The answer to day 2 part 2 is: {(100 * answer2[0]) + answer2[1]}")
Exemple #2
0
def test_computer_2():
    computer = mod2.ShipComputer([2, 3, 0, 3, 99])
    assert computer.runprogram() == [2, 3, 0, 6, 99]
Exemple #3
0
def test_computer_4():
    computer = mod2.ShipComputer([1, 1, 1, 4, 99, 5, 6, 0, 99])
    assert computer.runprogram() == [30, 1, 1, 4, 2, 5, 6, 0, 99]
Exemple #4
0
def test_computer_1():
    computer = mod2.ShipComputer([1, 0, 0, 0, 99])
    assert computer.runprogram() == [2, 0, 0, 0, 99]
Exemple #5
0
def test_computer_3():
    computer = mod2.ShipComputer([2, 4, 4, 5, 99, 0])
    assert computer.runprogram() == [2, 4, 4, 5, 99, 9801]