Skip Navigation

🏭 - 2024 DAY 15 SOLUTIONS - 🏭

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

11

You're viewing a single thread.

11 comments
  • 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

    Code

    I 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#
    $ #[email protected].#
    $ #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
    
11 comments