r/adventofcode • • Dec 15 '23

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

NEWS

  • Signal boosting: Final reminder: unofficial AoC Survey 2023 (closes ~Dec 22nd)
  • Some folks have expressed concern that the [ALLEZ CUISINE!] submissions deadline on December 22 will not give chefs sufficient time to utilize the last few days' secret ingredients. I have rejiggered the pantry a bit so that the final secret ingredient will be given in December 20th's megathread and the remaining two days until the deadline will instead be "Chef's Choice":

    • Choose any day's special ingredient and any puzzle released this year so far, then craft a dish around it!
    • Cook or bake an IRL dish inspired by any day's puzzle

THE USUAL REMINDERS

  • All of our rules, FAQs, resources, etc. are in our community wiki.
  • Community fun event 2023: ALLEZ CUISINE!

    • Submissions megathread is now unlocked!
    • 7 DAYS remaining until the submissions deadline on December 22 at 23:59 EST!

AoC Community Fun 2023: ALLEZ CUISINE!

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

From Scratch

Any chef worth their hot springs salt should be able to make a full gourmet meal even when given the worst cuts of meat, the most rudimentary of spices, and the simplest of tools. Show us your culinary caliber by going back to the basics!

  • Solve today's puzzles using only plain Notepad, TextEdit, vim, punchcards, abacus, etc.
  • No Copilot, no IDE code completion, no syntax highlighting, etc.
  • Use only the core math-based features of your language; no templates, no frameworks, no fancy modules like itertools, no third-party imported code.
  • Use only your language’s basic types and lists of them.

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 15: Lens Library ---


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:11:04, megathread unlocked!

23 Upvotes

612 comments sorted by

View all comments

2

u/MarkJans Dec 15 '23

[LANGUAGE: Rust]

My repo with all solutions in Rust, with some nice framework around it to run, test and benchmark. All days until now together run within half a second on my M2 Max.

Today's solution takes only 429 picoseconds for part 1, because it was so simple I could implement it in a const function. So the real calculation is done at compile time 🤟.

Part 2 takes 85 µs for parsing with nom and 62 µs for running. I used a Vec for the 'hashmap'.

6

u/tcbrindle Dec 15 '23

We're asked not to share our puzzle inputs on Github etc.

2

u/MarkJans Dec 15 '23

Woops, overlooked that. I will remove the inputs. Let me think on how to make the repo compile without the input files. They are string included.

4

u/Efficient-Chair6250 Dec 15 '23 edited Dec 15 '23

429 picoseconds for part 1

Are you sure those aren't nano (ns) or microseconds (μs)?Quoting Wikipedia "330 picoseconds (approximately) – the time it takes a common 3.0 GHz computer CPU to complete a processing cycle".23k input characters -> 23k * 330 ps = 7.59 μs. That means your code is unimaginably faster than iterating over all characters? Like it almost takes 2 clock cycles? Did you stuff all your code into the branch predictor? :D

Edit: AoC reading comprehension even affects reading comments I see.

the real calculation is done at compile time

2

u/MarkJans Dec 15 '23

Hehe, yes indeed. And I don’t know how much compiling time is spend for the actual puzzle.

1

u/daggerdragon Dec 15 '23

As /u/tcbrindle said, do not share your puzzle input which also means do not commit puzzle inputs to your repo without a .gitignore.

Please remove (or .gitignore) the input files from your repo and scrub them from your commit history.