Exemple #1
0
def test():
    computer1 = IntComputer([1, 0, 0, 0, 99])
    assert computer1.run() == [2, 0, 0, 0, 99]

    computer2 = IntComputer([2, 3, 0, 3, 99])
    assert computer2.run() == [2, 3, 0, 6, 99]

    computer3 = IntComputer([2, 4, 4, 5, 99, 0])
    assert computer3.run() == [2, 4, 4, 5, 99, 9801]

    computer4 = IntComputer([1, 1, 1, 4, 99, 5, 6, 0, 99])
    assert computer4.run() == [30, 1, 1, 4, 2, 5, 6, 0, 99]
def main():
    for x in range(100):
        noun = x
        for y in range(100):
            verb = y
            computer = IntComputer(retrieve_opcode())
            computer.update(1, noun)
            computer.update(2, verb)
            run = computer.run()
            if run[0] == 19690720:
                print(
                    f'noun: {noun}, verb: {verb}, answer: {100 * noun + verb}')
                break
Exemple #3
0
def main():
    main_computer = IntComputer(retrieve_opcode())
    main_computer.update(1, 12)
    main_computer.update(2, 2)
    run = main_computer.run()
    print(run)