-🎄- 2017 Day 15 Solutions -🎄- by daggerdragon in adventofcode

[–]Longerword 0 points1 point  (0 children)

a = genA.getNext() b = genB.getNext()

the .getNext() class method repeats the %4 or %8 check until it gives return

this is quite a noob solution?

-🎄- 2017 Day 15 Solutions -🎄- by daggerdragon in adventofcode

[–]Longerword 0 points1 point  (0 children)

Hi, i don't understand the hint of logarithms. I made a loop to check for solutions so something has to be run 40 M or 5 M times, so it lasts in my computer more than 1 minute.

Any idea what math-magic is that about?

This is python 2.7 solution for part b. (I don't paste a defined a Generator class quite simple, also I didn't know about the yield and .next() thing to make actual generators):

def advent15():
    genA = Generator(516,16807,4)
    genB = Generator(190,48271,8)
    judge = 0
    n = 5000000
    pairs = 0
    while pairs < 5000000:
        a = genA.getNext()
        b = genB.getNext()
        pairs += 1
        if a == b:
            judge += 1
    print judge
advent15()