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

  • Quant@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    5 days 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

    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#
    $ #..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