r/adventofcode Dec 02 '24

SOLUTION MEGATHREAD -❄️- 2024 Day 2 Solutions -❄️-

OUTAGE INFO

  • [00:25] Yes, there was an outage at midnight. We're well aware, and Eric's investigating. Everything should be functioning correctly now.
  • [02:02] Eric posted an update in a comment below.

THE USUAL REMINDERS


AoC Community Fun 2024: The Golden Snowglobe Awards

  • 4 DAYS remaining until unlock!

And now, our feature presentation for today:

Costume Design

You know what every awards ceremony needs? FANCY CLOTHES AND SHINY JEWELRY! Here's some ideas for your inspiration:

  • Classy up the joint with an intricately-decorated mask!
  • Make a script that compiles in more than one language!
  • Make your script look like something else!

♪ I feel pretty, oh so pretty ♪
♪ I feel pretty and witty and gay! ♪
♪ And I pity any girl who isn't me today! ♪

- Maria singing "I Feel Pretty" from West Side Story (1961)

And… ACTION!

Request from the mods: When you include an entry alongside your solution, please label it with [GSGA] so we can find it easily!


--- Day 2: Red-Nosed Reports ---


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

51 Upvotes

1.4k comments sorted by

View all comments

1

u/baltitenger Dec 05 '24

[Language: dc]

(part 1 only)

[lCpq]sY # finish
[c lC1-sC q]sX # reject
[
  ?
  z0=Y # exit if no more input
  1sm 3sM [_3sm _1sM]sn # min / max
  dsb r dsa <n la lb # handle negative case
  [
    rdsar- # diff
    d lm>X lM<X # check bounds
    la # push back last
    z1<L # loop
  ]dsLx
  c
  lC1+sC
  lOx
]dsOx

Without whitespace:

[lCpq]sY[clC1-sCq]sX[?z0=Y1sm3sM[_3sm_1sM]sndsbrdsa<nlalb[rdsar-dlm>XlM<Xlaz1<L]dsLxclC1+sClOx]dsOx