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!

75 Upvotes

1.5k comments sorted by

View all comments

2

u/Wrenky Dec 04 '23

[LANGUAGE: Go]

github here. I'm enjoying samber/lo a bunch for the functional primitives, but does anybody know the correct functional pattern for dealing with a map like part2? This might be one of those cases where go just isn't a great language for functional stuff.

0

u/[deleted] Dec 04 '23

[deleted] — view deleted comment

1

u/Wrenky Dec 05 '23

Yeah, don't do functional stuff in Go.

Why not? I mean, functional patterns are just net good where the language supports them (like all of day3!) You get all sorts of assurances, and with samber/lo being written with generics the type assurances stretch all the way down.

I'm definitely avoiding it for any recursive situations (no tail call optimization!) or for situations with maps (doesn't seem like a good way to work with them functionally) but there is still a large space for functional stuff to work well with.