/aocg/ - Advent of Code 2018 General #32

Do You Want A Bikkie Edition

Previous thread: adventofcode.com/
>Advent of Code is a series of small programming puzzles for a variety of skill levels. They are self-contained and are just as appropriate for an expert who wants to stay sharp as they are for a beginner who is just learning to code. Each puzzle calls upon different skills and has two parts that build on a theme.
You need to register with an account but you can appear as anonymous.

Private leaderboard join code: 368748-e33dcae3
People who are inactive for 5 days will be kicked, but other leaderboards can be made if desired.

Alternative leaderboard for those waiting for inactives to be kicked from the first: 208834-4a1a9383

Attached: elves-cooking.jpg (670x424, 64K)

Other urls found in this thread:

pastebin.com/mJiC8Xkk
youtube.com/watch?v=bFtcLJVN8yg
pastebin.com/xmVzcW7w
twitter.com/NSFWRedditGif

I want to FUCK() that oven

BIGBOI INPUT:
123456789

def cook(recipes, part1=None, part2=None):
recp = list(map(int, str(recipes)))
scores = [3, 7]
e1, e2 = 0, 1
while part2 is None:
for r in str(scores[e1] + scores[e2]):
scores.append(int(r))
if part1 is None and len(scores) >= recipes + 10:
part1 = "".join(map(str, scores[recipes:]))
if all(recp[-(i+1)] == scores[-(i+1)] for i in range(len(recp))):
part2 = len(scores) - len(recp)
break
e1 = (e1 + scores[e1] + 1) % len(scores)
e2 = (e2 + scores[e2] + 1) % len(scores)

return part1, part2

print("Part (1, 2):", *cook(recipes))

$ time python3 14.py ~200MiB RAM usage
Surely there's got to be some kind of mathematical series that can model part 2, no?

>out of memory in pypy within a minute
Shit.

Turns out 82% of the first 100 numbers ending in 1 are edge cases.

use your hdd BITCH

I guess I could code that manually, I kind of expected pypy to let it swap out, but there must be some sort of limit.

12 minutes later, 2.5GiB ram, still running. Going to bed and hope to wake up to an efficient algorithm solution.

user, my 32 gigs of ram ran out and I started eating into swap. Expect the process to get OOM killed by the end of the hour.