this post was submitted on 15 Dec 2024
12 points (92.9% liked)

Advent Of Code

920 readers
26 users here now

An unofficial home for the advent of code community on programming.dev!

Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

AoC 2024

Solution Threads

M T W T F S S
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25

Rules/Guidelines

Relevant Communities

Relevant Links

Credits

Icon base by Lorc under CC BY 3.0 with modifications to add a gradient

console.log('Hello World')

founded 1 year ago
MODERATORS
 

Day 15: Warehouse Woes

Megathread guidelines

  • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
  • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

FAQ

you are viewing a single comment's thread
view the rest of the comments
[–] Quant@programming.dev 1 points 10 hours ago* (last edited 10 hours ago)

Uiua

Put this one off for a bit and I'll put off part two for even longer because I don't want to deal with any pyramid-shapes of boxes at the moment.
The code for part one feels too long but it works and runs <2s so I'm happy with it for now ^^

Run with example input here

CodeI decided to split the movement instructions lines further for aesthetic reasons when opening it in the online uiua pad since newlines are thrown out anyways.

$ ##########
$ #..O..O.O#
$ #......O.#
$ #.OO..O.O#
$ #..O@..O.#
$ #O#..O...#
$ #O..O..O.#
$ #.OO.O.OO#
$ #....O...#
$ ##########
$ 
$ <vv>^<v^>v>^vv^v>v<>v^v<v<^vv<<<^><
$ <><>>v<vvv<>^v^>^<<<><<v<<<v^vv^v>^
$ vvv<<^>^v^^><<>>><>^<<><^vv^^<>vvv<
$ >><^^v>^>vv<>v<<<<v<^v>^<^^>>>^<v<v
$ ><>vv>v^v^<>><>>>><^^>vv>v<^^^>>v^v
$ ^<^^>v^^>v^<^v>v<>>v^v^<v>v^^<^^vv<
$ <<v<^>>^^^^>>>v^<>vvv^><v<<<>^^^vv^
$ <vvv>^>v<^^^^v<>^>vvvv><>>v^<<^^^^^
$ ^><^><>>><>^^<<^^v>>><^<v>^<vv>>v>>
$ >^v><>^v><<<<v>>v<v<v>vvv>^<><<>^><
$ ^>><>^v<><^vvv<^^<><v<<<<<><^v<<<><
$ <<^^<v<^^^><^>>^<v^><<<^>>^v<v^v<v^
$ >^>>^v>vv>^<<^v<>><<><<v<<v><>v<^vv
$ <<<>^^v^>^^>>><<^v>>v^v><^^>>^<>vv^
$ <><^^>^^^<><vvvvv^v<v<<>^v<v>v<<^><
$ <><<><<<^^<<<^<<>><<><^^^>^^<>^>v<>
$ ^^>vv<^v^v<vv>^<><v<^v>^^^>>>^^vvv^
$ >vvv<>>>^<^>>>>>^<<^v>^vvv<>^<><<v>
$ v^^>>><<^^<>>^v^<v^vv<>v^<<>^<^v^v>
$ <^<<<><<^<v><v<>vv>>v><v^<vv<>v^<<^

Pos ← :Β°βŠŸβ™­βŠšβŠΈβŒ•@@
Move ← (
  βŠΈβŠ—@.
  ⍣(+₁⍀.β—‘(β‰ βŠ™β§»)
    βœβ†™β£(⬚@.↻₋₁⍀.=βŠƒ(⧻|βŠ—@#).)∘
  )β‹…βˆ˜
)

PartOne ← (
  # &rs ∞ &fo "input-15.txt"
  βŠœβ–‘Β¬β¦·"\n\n".
  βˆ©Β°β–‘Β°βŠŸ
  : βŠ™(β–½β‰ @\n.) βŠœβˆ˜β‰ @\n.
  β†˜β‚„βŠ›βŠ‚"^>v<"
  ⍒(βŠƒβ†˜β‚βŠ’
    βŠ™(⟜(⨬(⍉|∘)β—Ώβ‚‚)
      ⟜(⨬(⍜(β†˜βŠ™βŠ‘)Move Pos
        | ⍜(β‡Œβ†™βŠ™βŠ‘)Move +₁Pos
        )=₀◿₃)
      ⨬(⍉|∘)β—Ώβ‚‚
    )
  | β‰ 0⧻)
  β—Œ
  /+≑/+Γ—[100_1]βŠšβŒ•@O
)

PartTwo ← (
  ""
)

&p "Day 15:"
&pf "Part 1: "
&p PartOne
&pf "Part 2: "
&p PartTwo