Unable to load image

ADVENT OF CODE DAY 11: MONKEY BUSINESS :marseymonke:

Those FRICKING monkeys stole your stuff! Get it back! :soycry: :!marseymonke:

(Also, remember to leave a comment if you did something interesting :marseylove:)

35
Jump in the discussion.

No email address required.

That second half took me longer than I would've liked... I understood the problem but I was trying to do crazy stuff with prime factors which were way off-track. Also hard-coded the inputs because fuck that noise.

monke = [[85, 77, 77], [80, 99], [74, 60, 74, 63, 86, 92, 80], [71, 58, 93, 65, 80, 68, 54, 71], [97, 56, 79, 65, 58], [77], [99, 90, 84, 50], [50, 66, 61, 92, 64, 78]]
count = [0,0,0,0,0,0,0,0]

def take_turn(i, n):
    div_check = [[19, 6, 7], [3, 3, 5], [13, 0, 6], [7, 2, 4], [5, 2, 0], [11, 4, 3], [17, 7, 1], [2, 5, 1]]
    vals = [n*7, n*11, n+8, n+7, n+5, n+4, n*n, n+3]
    val = vals[i]
    if val%div_check[i][0] == 0:
        return div_check[i][1], val%(2*3*5*7*11*13*17*19)
    else:
        return div_check[i][2], val%(2*3*5*7*11*13*17*19)

for n in range(10000):
    for m in range(len(monke)):
        for i in range(len(monke[m])):
            count[m] += 1
            item = monke[m][0]
            monke[m] = monke[m][1:]
            new_monke, new_val = take_turn(m, item)
            monke[new_monke] = [new_val] + monke[new_monke]
count.sort()
print(count[-1]*count[-2])
Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.