Day 8 - last couple of days i had gotten lazy, looked at a few model solutions before writing my own, so today i wrote out my pseudo-code and cracked on without looking at any solutions or googling any functions etc. Result is probably not the neatest code but got the answer correct.
One question - i couldn't figure out how to recursively operate without the below, which seems kind of stupid given i don't exit with the flag being true. maybe something like putting it all into a recursive function would have worked? i might try re-writing that later.
flag = False
accum = 0
# part1
while not flag:
if bootlist[line] > 0: break
if boot[line][0] == 'jmp': line += int(boot[line][1])
elif boot[line][0] == 'nop': line += 1
elif boot[line][0] == 'acc':
accum += int(boot[line][1])
bootlist[line] = accum
line += 1
Day 8 - last couple of days i had gotten lazy, looked at a few model solutions before writing my own, so today i wrote out my pseudo-code and cracked on without looking at any solutions or googling any functions etc. Result is probably not the neatest code but got the answer correct.
One question - i couldn't figure out how to recursively operate without the below, which seems kind of stupid given i don't exit with the flag being true. maybe something like putting it all into a recursive function would have worked? i might try re-writing that later.
https://github.com/lewfowls/AoC2020/blob/main/day8Code.py