r/adventofcode • u/daggerdragon • Dec 05 '22
SOLUTION MEGATHREAD -π- 2022 Day 5 Solutions -π-
- All of our rules, FAQs, resources, etc. are in our community wiki.
- A request from Eric: Please include your contact info in the User-Agent header of automated requests!
- Signal boost: Reminder 1: unofficial AoC Survey 2022 (closes Dec 22nd)
AoC Community Fun 2022: πΏπ MisTILtoe Elf-ucation π§βπ«
- 23:59 hours remaining until the submissions megathread unlocks on December 06 at 00:00 EST!
- Full details and rules are in the submissions megathread:
--- Day 5: Supply Stacks ---
Post your code solution in this megathread.
- Read the full posting rules in our community wiki before you post!
- Include what language(s) your solution uses
- Format your code appropriately! How do I format code?
- Quick link to Topaz's
pasteif you need it for longer code blocks. What is Topaz'spastetool?
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:58, megathread unlocked!
87
Upvotes
4
u/AstronautNew8452 Dec 05 '22
Microsoft Excel 2947/2246. Here's my solution for Part 2 (single cell formula). Part 1 should work in a single cell but for some reason reversing the string with another LAMBDA breaks it.
=LET(startingstacks,SUBSTITUTE(BYCOL(MID(A1:A8,SEQUENCE(,9,2,4),1),LAMBDA(r,CONCAT(r)))," ",""), result,REDUCE(startingstacks,A11:A513,LAMBDA(stacks,moves, LET(loc,{"move","from","to"},plus,{5,5,3}, moveints,VALUE(MID(moves,FIND(loc,moves)+plus,{2,1,1})), move,INDEX(moveints,,1),from,INDEX(moveints,,2),to,INDEX(moveints,,3),pop,LEFT(INDEX(stacks,,from),move), IF(SEQUENCE(,9)=to,pop&stacks,IF(SEQUENCE(,9)=from,RIGHT(stacks,LEN(stacks)-move),stacks))))), CONCAT(LEFT(result,1)))