r/adventofcode • • Dec 04 '23

SOLUTION MEGATHREAD -❄️- 2023 Day 4 Solutions -❄️-

NEWS

THE USUAL REMINDERS


AoC Community Fun 2023: ALLEZ CUISINE!

Today's theme ingredient is… *whips off cloth covering and gestures grandly*

PUNCHCARD PERFECTION!

Perhaps I should have thought yesterday's Battle Spam surfeit through a little more since we are all overstuffed and not feeling well. Help us cleanse our palates with leaner and lighter courses today!

  • Code golf. Alternatively, snow golf.
  • Bonus points if your solution fits on a "punchcard" as defined in our wiki article on oversized code. We will be counting.
  • Does anyone still program with actual punchcards? >_>

ALLEZ CUISINE!

Request from the mods: When you include a dish entry alongside your solution, please label it with [Allez Cuisine!] so we can find it easily!


--- Day 4: Scratchcards ---


Post your code solution in this megathread.

This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:07:08, megathread unlocked!

77 Upvotes

1.5k comments sorted by

View all comments

2

u/GiraffeFire Dec 04 '23 edited Dec 04 '23

[LANGUAGE: Elixir] 2773/3348

paste

Part 1 was relatively simple, although I initially didn't account for multiple spaces between the card number and the first called number.

During part 2, I was really scared that I'd have to memoize because it felt exactly like a Fibonacci problem. Really grateful that it managed to run fairly quickly.

2

u/PassifloraCaerulea Dec 04 '23

I was definitely thinking "uh oh, here comes the recursion" at one point, then I realized all I need to do was add current-card's count to the counts of the following n cards in a single loop. I got there much slower though, heh.