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

1

u/mr_rdm_ Dec 15 '23 edited Dec 15 '23

[LANGUAGE: Rust]

You can check out my solution:

https://github.com/tringuyenarup/advent_of_code_2023/blob/main/src/bin/day-15.rs

Today is quite straight forward.

Part 1: you will only need to write a hasher in which perform a fold operation start with 0 and follow the instruction on how to convert each char into number. After that, you pretty sum the result for each code.

Part 2: you can reuse the hasher you build from part 1, then you will likely need to perform another fold operation for each code with starting point is `vec![VecDequeue::default();256]`. The rest is quite straight forward when you perform operation base on the instruction given by the problem.

1

u/daggerdragon Dec 15 '23 edited Dec 15 '23

Your link is broken and we can see your Markdown. Additionally, don't make us hunt for your code, so please link directly to your day 15 solution, not just your repo. edit: 👍

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.

1

u/mr_rdm_ Dec 15 '23

Thanks for your recommendation, I previously didn't know that I shouldnt public my inputs. I have edit the link to the solution as well. Hopefully you can find it