Esempio n. 1
0
def check(x, y):
    if (x, y) in visited: return visited[(x, y)]
    else:
        drone = intcodecomputer.IntComputer("Drone", copy.copy(day19_input),
                                            [x, y], False)
        drone.compute()
        visited[(x, y)] = drone.lastoutput[0]
        return drone.lastoutput[0]
Esempio n. 2
0
File: day15.py Progetto: qreoct/aoc
    19, 31, 1, 1, 47, 88, 15, 31, 25, 94, 4, 11, 95, 87, 16, 77, 86, 92, 3, 2,
    48, 39, 52, 62, 22, 63, 1, 70, 18, 61, 78, 14, 12, 50, 75, 10, 30, 2, 10,
    96, 13, 58, 87, 9, 90, 3, 83, 5, 13, 28, 3, 67, 66, 21, 46, 10, 1, 70, 64,
    8, 10, 50, 13, 22, 93, 3, 58, 13, 58, 2, 69, 1, 44, 2, 18, 22, 61, 61, 25,
    36, 20, 7, 31, 6, 2, 7, 29, 2, 27, 22, 93, 16, 25, 8, 79, 93, 22, 2, 29,
    27, 12, 56, 48, 34, 6, 40, 14, 13, 8, 14, 2, 8, 64, 32, 19, 18, 99, 22, 83,
    83, 79, 16, 84, 58, 22, 88, 19, 31, 18, 35, 18, 31, 85, 20, 30, 16, 75, 16,
    46, 16, 65, 16, 3, 44, 6, 2, 65, 97, 24, 40, 20, 25, 31, 88, 14, 66, 20,
    13, 11, 76, 18, 43, 67, 13, 92, 47, 9, 81, 78, 20, 51, 12, 7, 43, 17, 24,
    99, 14, 4, 89, 13, 84, 48, 13, 60, 13, 51, 23, 66, 7, 61, 19, 91, 17, 72,
    64, 48, 10, 74, 13, 85, 8, 76, 11, 72, 3, 32, 22, 37, 80, 44, 18, 86, 50,
    71, 5, 36, 21, 76, 23, 64, 23, 61, 40, 62, 24, 61, 0, 0, 21, 21, 1, 10, 1,
    0, 0, 0, 0, 0, 0
]

oxygendroid = intcodecomputer.IntComputer("Oxygen Droid",
                                          copy.copy(day15_input), [], False)

movement_commands = {'n': 1, 's': 2, 'w': 3, 'e': 4}

screen = []


#making a 15x15 screen
def makescreen(y, x=None):
    if x == None: x = y
    for i in range(y):
        mylist = []
        for ii in range(x):
            mylist.append(' ')
        screen.append(mylist)
Esempio n. 3
0
    1002, 64, 2, 64, 109, 7, 21108, 45, 43, 2, 1005, 1013, 557, 1106, 0, 563,
    4, 547, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, -5, 1207, -3, 34, 63, 1005,
    63, 583, 1001, 64, 1, 64, 1106, 0, 585, 4, 569, 1002, 64, 2, 64, 109, 5,
    21108, 46, 46, 5, 1005, 1016, 607, 4, 591, 1001, 64, 1, 64, 1105, 1, 607,
    1002, 64, 2, 64, 109, -12, 2108, 20, 8, 63, 1005, 63, 627, 1001, 64, 1, 64,
    1105, 1, 629, 4, 613, 1002, 64, 2, 64, 109, 24, 1206, -3, 647, 4, 635,
    1001, 64, 1, 64, 1105, 1, 647, 1002, 64, 2, 64, 109, -30, 2108, 32, 8, 63,
    1005, 63, 665, 4, 653, 1106, 0, 669, 1001, 64, 1, 64, 1002, 64, 2, 64, 109,
    22, 1208, -9, 20, 63, 1005, 63, 691, 4, 675, 1001, 64, 1, 64, 1106, 0, 691,
    1002, 64, 2, 64, 109, -4, 21102, 47, 1, 3, 1008, 1014, 49, 63, 1005, 63,
    715, 1001, 64, 1, 64, 1105, 1, 717, 4, 697, 1002, 64, 2, 64, 109, -10,
    2101, 0, 1, 63, 1008, 63, 36, 63, 1005, 63, 743, 4, 723, 1001, 64, 1, 64,
    1105, 1, 743, 1002, 64, 2, 64, 109, 16, 1201, -9, 0, 63, 1008, 63, 28, 63,
    1005, 63, 769, 4, 749, 1001, 64, 1, 64, 1105, 1, 769, 1002, 64, 2, 64, 109,
    2, 2105, 1, 5, 4, 775, 1001, 64, 1, 64, 1106, 0, 787, 1002, 64, 2, 64, 109,
    -5, 1202, -6, 1, 63, 1008, 63, 26, 63, 1005, 63, 807, 1106, 0, 813, 4, 793,
    1001, 64, 1, 64, 1002, 64, 2, 64, 109, -16, 2107, 37, 4, 63, 1005, 63, 833,
    1001, 64, 1, 64, 1105, 1, 835, 4, 819, 1002, 64, 2, 64, 109, 2, 2101, 0, 1,
    63, 1008, 63, 34, 63, 1005, 63, 855, 1105, 1, 861, 4, 841, 1001, 64, 1, 64,
    1002, 64, 2, 64, 109, 19, 1205, 2, 875, 4, 867, 1105, 1, 879, 1001, 64, 1,
    64, 1002, 64, 2, 64, 109, -2, 1208, -8, 23, 63, 1005, 63, 899, 1001, 64, 1,
    64, 1106, 0, 901, 4, 885, 4, 64, 99, 21101, 0, 27, 1, 21102, 915, 1, 0,
    1106, 0, 922, 21201, 1, 61455, 1, 204, 1, 99, 109, 3, 1207, -2, 3, 63,
    1005, 63, 964, 21201, -2, -1, 1, 21102, 942, 1, 0, 1105, 1, 922, 22102, 1,
    1, -1, 21201, -2, -3, 1, 21102, 1, 957, 0, 1105, 1, 922, 22201, 1, -1, -2,
    1106, 0, 968, 22101, 0, -2, -2, 109, -3, 2105, 1, 0
]

BOOST = intcodecomputer.IntComputer("BOOST", copy.copy(inputday9), [1], False)
BOOST.compute()
Esempio n. 4
0
File: day13.py Progetto: qreoct/aoc
    86, 47, 2, 80, 41, 15, 60, 50, 24, 31, 24, 83, 34, 19, 40, 55, 42, 25, 93,
    39, 85, 29, 98, 95, 67, 55, 62, 4, 26, 19, 61, 93, 14, 11, 45, 50, 40, 81,
    61, 57, 17, 44, 3, 75, 7, 74, 20, 70, 2, 63, 29, 52, 48, 47, 29, 90, 8, 36,
    39, 77, 62, 97, 11, 43, 31, 13, 25, 5, 66, 2, 6, 20, 49, 89, 48, 67, 79,
    66, 74, 48, 79, 45, 5, 35, 31, 33, 50, 95, 23, 56, 33, 40, 75, 24, 81, 84,
    56, 35, 96, 11, 95, 29, 7, 55, 17, 37, 18, 20, 32, 41, 4, 71, 74, 67, 7,
    46, 1, 86, 70, 9, 13, 40, 17, 12, 64, 31, 65, 60, 40, 4, 6, 42, 57, 89, 15,
    40, 53, 88, 14, 2, 35, 5, 16, 44, 62, 6, 53, 83, 76, 87, 26, 82, 1, 7, 25,
    66, 65, 53, 60, 52, 57, 64, 9, 16, 88, 2, 93, 33, 62, 82, 27, 17, 29, 17,
    40, 68, 83, 4, 28, 83, 62, 6, 91, 45, 69, 30, 8, 39, 55, 78, 97, 46, 13, 2,
    7, 80, 74, 19, 68, 20, 2, 5, 35, 55, 62, 25, 32, 55, 3, 76, 92, 70, 62, 36,
    73, 14, 55, 12, 4, 25, 46, 25, 17, 41, 63, 19, 74, 70, 86, 4, 80, 50, 97,
    44, 65, 51, 44, 7, 78, 59, 351522
]
#day13_input=[4,2,99]
arcade = intcodecomputer.IntComputer("Arcade", copy.copy(day13_input), [1],
                                     False)

score = 0
ballX = None
paddleX = None

screen = []


#making a 50x50 screen
def makescreen(y, x=None):
    if x == None: x = y
    for i in range(y):
        mylist = []
        for ii in range(x):
            mylist.append(' ')
Esempio n. 5
0
    75, 79, 68, 78, 66, 78, 60, -10, 27, 64, 66, 65, 67, 12, 53, 97, 83, 93,
    105, 105, 87, 91, 83, 25, 24, 23, 3380, 4653, 2097179, 0, 3469, 4665,
    33554460, 0, 4361, 4676, 30, 0, 3607, 4682, 30, 1872, 3252, 4690, 1055, 0,
    4289, 4694, 32, 1796, 3859, 4705, 4129, 0, 3309, 4710, 66, 0, 4008, 4719,
    35, 1850, 3939, 4731, 67108900, 0, 3649, 4745, 37, 1818, 4100, 4765,
    536870950, 0, 4214, 4771, 39, 1829, 11, 91, 99, 98, 86, 17, 98, 80, 98, 86,
    91, 89, 10, 89, 86, 98, 87, 107, 17, 83, 80, 92, 82, 5, 104, 105, 110, 107,
    92, 7, 105, 96, 102, 106, 100, 98, 102, 3, 106, 113, 98, 10, 91, 104, 87,
    84, 98, 86, 16, 95, 93, 81, 4, 95, 106, 99, 103, 8, 103, 105, 100, 86, 97,
    88, 96, 101, 11, 98, 99, 95, 102, 86, 94, 15, 90, 78, 98, 76, 13, 102, 87,
    94, 89, 82, 93, 91, 80, 96, 77, 93, 87, 89, 19, 84, 85, 76, 88, 93, 8, 76,
    82, 74, 71, 87, 84, 80, 77, 64, 69, 75, 65, 79, 5, 104, 111, 109, 93, 111,
    13, 92, 96, 87, 89, 93, 87, 97, 81, 11, 86, 88, 87, 87
]

droid = intcodecomputer.IntComputer("droid", copy.copy(day25_input), [], False)


def processdroid(droid):
    droid.compute()
    os.system('cls')
    for each in droid.lastoutput:
        print(chr(each), end="")
    droid.lastoutput.clear()


def commanddroid(droid):
    myinput = input("INPUT: ")
    instruction = []
    for char in myinput:
        instruction.append(ord(char))
Esempio n. 6
0
    101, 1, 9, 9, 4, 9, 3, 9, 102, 2, 9, 9, 4, 9, 3, 9, 1002, 9, 2, 9, 4, 9, 3,
    9, 1002, 9, 2, 9, 4, 9, 3, 9, 101, 2, 9, 9, 4, 9, 99, 3, 9, 1002, 9, 2, 9,
    4, 9, 3, 9, 1001, 9, 1, 9, 4, 9, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9, 1002, 9,
    2, 9, 4, 9, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9,
    102, 2, 9, 9, 4, 9, 3, 9, 1001, 9, 2, 9, 4, 9, 3, 9, 101, 2, 9, 9, 4, 9, 3,
    9, 101, 1, 9, 9, 4, 9, 99, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9, 101, 1, 9, 9,
    4, 9, 3, 9, 102, 2, 9, 9, 4, 9, 3, 9, 102, 2, 9, 9, 4, 9, 3, 9, 102, 2, 9,
    9, 4, 9, 3, 9, 1001, 9, 1, 9, 4, 9, 3, 9, 1001, 9, 1, 9, 4, 9, 3, 9, 101,
    2, 9, 9, 4, 9, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9, 101, 2, 9, 9, 4, 9, 99
]
ans = []
ansphase = []
l = list(permutations(range(5, 10)))
for i in l:

    intcA = intcodecomputer.IntComputer("A", copy.copy(true_list), [i[0], 0],
                                        False)
    intcB = intcodecomputer.IntComputer("B", copy.copy(true_list), [i[1]],
                                        False)
    intcC = intcodecomputer.IntComputer("C", copy.copy(true_list), [i[2]],
                                        False)
    intcD = intcodecomputer.IntComputer("D", copy.copy(true_list), [i[3]],
                                        False)
    intcE = intcodecomputer.IntComputer("E", copy.copy(true_list), [i[4]],
                                        False)

    last = []
    intcA.compute()
    while intcA.lastoutput:
        intcB.inputqueue.append(intcA.lastoutput[0])
        intcA.lastoutput.pop()
        intcB.compute()
Esempio n. 7
0
File: day19.py Progetto: qreoct/aoc
    -1, -1, 22201, -3, -1, 2, 22102, 1, -4, 1, 21101, 384, 0, 0, 1105, 1, 303,
    1105, 1, 415, 21202, -4, -1, -4, 22201, -4, -3, -4, 22202, -3, -2, -2,
    22202, -2, -4, -4, 22202, -3, -2, -3, 21202, -4, -1, -2, 22201, -3, -2, 1,
    22102, 1, 1, -4, 109, -5, 2106, 0, 0
]

x = y = 100

visited = {}
Left = False
while True:
    #print("checking {} {}".format(x,y),end="\r")
    if (x, y) in visited:
        output_1 = visited[(x, y)]
    else:
        drone1 = intcodecomputer.IntComputer("Drone", copy.copy(day19_input),
                                             [x, y], False)
        drone1.compute()
        visited[(x, y)] = drone1.lastoutput[0]
        output_1 = drone1.lastoutput[0]
    if output_1 == 0:
        y += 1
        x += 1
        if x == 800:
            x = left_edge
            y += 1
            print("{} {}".format(x, y))
            Left = False
        continue
    if Left == False:
        if output_1 == 1:
            left_edge = x
Esempio n. 8
0
    1105, 1, 579, 204, -2, 104, 10, 99, 21207, -3, 22, -1, 1206, -1, 1138,
    2102, 1, -5, 1176, 1202, -4, 1, 0, 109, -6, 2106, 0, 0, 14, 5, 46, 1, 3, 1,
    36, 13, 1, 1, 36, 1, 9, 1, 1, 1, 1, 1, 32, 13, 1, 7, 30, 1, 3, 1, 7, 1, 3,
    1, 1, 1, 1, 1, 30, 1, 3, 1, 7, 1, 3, 1, 1, 1, 1, 1, 21, 10, 3, 1, 7, 1, 3,
    1, 1, 1, 1, 1, 21, 1, 7, 6, 7, 1, 3, 1, 1, 1, 1, 1, 21, 1, 7, 1, 12, 1, 3,
    1, 1, 1, 1, 1, 21, 1, 7, 1, 4, 13, 1, 1, 1, 1, 21, 1, 7, 1, 4, 1, 7, 1, 5,
    1, 1, 1, 21, 1, 7, 1, 4, 1, 1, 13, 1, 1, 21, 1, 7, 1, 4, 1, 1, 1, 5, 1, 7,
    1, 21, 1, 7, 1, 4, 1, 1, 1, 5, 1, 5, 13, 7, 13, 4, 1, 1, 1, 5, 1, 5, 1, 1,
    1, 9, 1, 7, 1, 3, 1, 12, 1, 1, 1, 5, 9, 9, 1, 7, 1, 3, 1, 12, 1, 1, 1, 11,
    1, 11, 1, 7, 1, 3, 1, 12, 1, 1, 1, 1, 9, 1, 1, 11, 1, 7, 1, 3, 7, 6, 1, 1,
    1, 1, 1, 7, 1, 1, 1, 11, 1, 7, 1, 16, 1, 1, 13, 11, 1, 7, 1, 16, 1, 3, 1,
    7, 1, 13, 1, 7, 1, 16, 5, 7, 1, 13, 1, 7, 1, 28, 1, 13, 1, 7, 1, 28, 1, 13,
    1, 7, 1, 28, 1, 13, 1, 7, 1, 28, 1, 13, 9, 28, 1, 50, 1, 50, 1, 50, 13, 22
]

camera = intcodecomputer.IntComputer("Camera", copy.copy(day17_input), [],
                                     False)
camera.compute()

camera_feed = camera.lastoutput

screen = []


def makescreen(y, x=None):
    global screen
    if x == None: x = y
    for i in range(y):
        mylist = []
        for ii in range(x):
            mylist.append(' ')
        screen.append(mylist)