예제 #1
0
파일: Day19.py 프로젝트: jdeloren/aoc
def second():
    def detection(x, y):
        if x > n and y > n:
            return True if radar[x - n][y - n:y].count(1) == n and [
                m[y - n] for m in radar[x - n:x]
            ].count(1) == n else False
        else:
            return False

    values = DataAnalyzer.int_csv("2019day19.txt")[0]
    cpu = Computer.IntCode(values,
                           extend=True,
                           interrupt=False,
                           auto=False,
                           x=25000)
    done, i, j, size, n = False, 0, 0, 1700, 100
    radar = [[0 for i in range(size)] for j in range(size)]

    for i in range(size):
        for j in range(size):
            cpu.reset([i, j])
            cpu.start()
            radar[i][j] = cpu.output()[0]
            done = detection(i + 1, j + 1)
            if done:
                break

        if done:
            break

    print(
        f"(19.2) LOCATED: {done}, {n}x{n} block at {i-n+1},{j-n+1} :: ship math = {(i-n+1)*10000 + j-n+1}"
    )
예제 #2
0
파일: Day13.py 프로젝트: jdeloren/aoc
def first():
    values = DataAnalyzer.int_csv("2019day13.txt")[0]
    computer = Computer.IntCode(values, extend=True, auto=True)

    count = 0
    output = computer.output()
    for i in range(0, len(output), 3):
        count += 1 if output[i+2] == 2 else 0

    print(f"(13.1) Block tile count: {count}")
예제 #3
0
파일: Day19.py 프로젝트: jdeloren/aoc
def first():
    values = DataAnalyzer.int_csv("2019day19.txt")[0]
    count = 0
    cpu = Computer.IntCode(values, extend=True, interrupt=False, auto=False)

    for i in range(50):
        for j in range(50):
            cpu.reset([i, j])
            cpu.start()
            count += 1 if cpu.output()[0] == 1 else 0
    print(f"(19.1) affected points: {count}")
예제 #4
0
def first():
    values = [
        109, 1, 204, -1, 1001, 100, 1, 100, 1008, 100, 16, 101, 1006, 101, 0,
        99
    ]
    computer = Computer.IntCode(values, extend=True, auto=True)
    print(f"(test) {computer.output()}")

    values = [1102, 34915192, 34915192, 7, 4, 7, 99, 0]
    computer = Computer.IntCode(values, extend=True, auto=True)
    print(f"(test) {computer.output()[0]}")

    values = DataAnalyzer.int_csv("2019day9.txt")[0]
    computer = Computer.IntCode(values, [1], extend=True, auto=True)
    print(f"(9.1) {computer.output()[0]}")
예제 #5
0
파일: Day7.py 프로젝트: jdeloren/aoc
def second():
    configuration = {
        0: 1,
        1: 2,
        2: 3,
        3: 4,
        4: 0
    }

    inputs = [3, 26, 1001, 26, -4, 26, 3, 27, 1002, 27, 2, 27, 1, 27, 26, 
              27, 4, 27, 1001, 28, -1, 28, 1005, 28, 6, 99, 0, 0, 5]

    sequencer(inputs, configuration, '56789', True)

    values = DataAnalyzer.int_csv("2019day7.txt")[0]
    print("(7.2)", end='')
    sequencer(values, configuration, '56789', True)
예제 #6
0
파일: Day7.py 프로젝트: jdeloren/aoc
def first():
    configuration = {
        0: 1,
        1: 2,
        2: 3,
        3: 4
    }

    inputs = [3, 15, 3, 16, 1002, 16, 10, 16, 1, 16, 15, 15, 4, 15, 99, 0, 0]
    sequencer(inputs, configuration, '01234')

    inputs = [3, 23, 3, 24, 1002, 24, 10, 24, 1002, 23, -1, 23, 101,
              5, 23, 23, 1, 24, 23, 23, 4, 23, 99, 0, 0]
    sequencer(inputs, configuration, '01234')
    inputs = [3, 31, 3, 32, 1002, 32, 10, 32, 1001, 31, -2, 31, 1007, 31, 0, 33, 1002,
              33, 7, 33, 1, 33, 31, 31, 1, 32, 31, 31, 4, 31, 99, 0, 0, 0]
    sequencer(inputs, configuration, '01234')

    print("(7.1) ", end='')
    inputs = DataAnalyzer.int_csv("2019day7.txt")[0]
    sequencer(inputs, configuration, '01234')
예제 #7
0
파일: Day13.py 프로젝트: jdeloren/aoc
def second():
    values = DataAnalyzer.int_csv("2019day13.txt")[0]
    codes = play(values.copy())
    print(f"(13.2) Final score: {codes}")
예제 #8
0
def second():
    values = DataAnalyzer.int_csv("2019day9.txt")[0]
    computer = Computer.IntCode(values, [2], extend=True, auto=True)
    print(f"(9.2) {computer.output()[0]}")
예제 #9
0
파일: Day5.py 프로젝트: jdeloren/aoc
def second():
    values = DataAnalyzer.int_csv("2019day5.txt")[0]
    computer = Computer.IntCode(values, [5], auto=True)
    print(f"(5.2) {computer.output()[0]}")
예제 #10
0
파일: Day5.py 프로젝트: jdeloren/aoc
def first():
    values = DataAnalyzer.int_csv("2019day5.txt")[0]
    computer = Computer.IntCode(values, [1], auto=True)
    print(f"(5.1) {computer.output()}")