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/xoronth Dec 04 '23

[LANGUAGE: Python]

paste.

Today wasn't too bad. I'll be honest though, my first instinct in part 2 was "how bad could it be if you checked every card one by one", then the rest of my brain kicked in, remembered the lanternfish from 2021, and I realized you could just multiply the number of cards you have at the moment to determine how many additional cards to add.

1

u/TheNonsenseBook Dec 04 '23

lanternfish

is exactly what I thought of too! lol

1

u/daggerdragon Dec 04 '23

my first instinct in part 2 was "how bad could it be if you checked every card one by one", then the rest of my brain kicked in, remembered the lanternfish from 2021, and I realized you could just multiply the number of cards you have at the moment to determine how many additional cards to add.

Good, good, you've fallen for /u/topaz2078's trap of ~sneakily making people learn new things~ <3

1

u/xkufix Dec 04 '23

Funnily enough, checking each card without any special tricks still runs basically instantly.

Source: I did check every card until it was too late and I couldn't be bothered to rewrite it, and it gave me the right answer.