Unable to load image

Advent of Code Day 5, AKA Stacks 101 :marseyinabox:

I actually stayed up to get a semi-decent score for once (being a eurocel for this is suffering). How are you all faring with shifting boxes around?

![](/images/16702184438592093.webp)

26
Jump in the discussion.

No email address required.

The code I got the stars with used the initial state written out explicitly, not parsed, like other peoples' solutions; otherwise unremarkable too. Afterward, I tried boredly golfing (edit: okay it's not actually golf it's just cleanup and smushing stuff together on one line despite the cleanup) the code a bit and getting rid of all the assumptions about line numbers. I'm not much good at code golf proper tbh this does work.

![](/images/16702286841351254.webp)

Jump in the discussion.

No email address required.

Is it bad if I program in a different language, but this code here still looks to me what it looks like to someone whos not a codecel? I'm gonna make it, r-right?

Jump in the discussion.

No email address required.

i solved the same puzzle in the same language and i still dont understand that image

Jump in the discussion.

No email address required.

its very obviously been optimized a few times over for the sake of brevity. it wasnt possible to discern that you might need a variable means of manipulating the stack from the first part of the problem, so move_step was devised after knowing that you will need to both pop the stacks and move the last n crates of the stack. its very well done, but also very unreadable because of how compact it is.

Jump in the discussion.

No email address required.

>not even trying to make :marseyyarn: all the variables names 1 char

ngmi at code :marseycapytrans: golf :P

Jump in the discussion.

No email address required.

From where is the parse function ?

Jump in the discussion.

No email address required.

https://pypi.org/project/parse/

I really missed having sscanf from <stdio.h> the first couple days and found a Python lib that seemed similar. It is very convenient, especially compared to my alternative plan of DIY adding some ergonomics to re.Match objects.

Jump in the discussion.

No email address required.

Scanf is like the evil twin of printf don‘t use it :marseyraging:

Jump in the discussion.

No email address required.

thanks, seems usefull :marseythumbsup:

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.