Day 16: Reindeer Maze

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

  • mykl@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    5 hours ago

    Uiua

    Uiua’s new builtin path operator makes this a breeze. Given a function that returns valid neighbours for a point and their relative costs, and another function to test whether you have reached a valid goal, it gives the minimal cost, and all relevant paths. We just need to keep track of the current direction as we work through the maze.

    Data   ≡°□°/$"_\n_" "###############\n#.......#....E#\n#.#.###.#.###.#\n#.....#.#...#.#\n#.###.#####.#.#\n#.#.#.......#.#\n#.#.#####.###.#\n#...........#.#\n###.#.#####.#.#\n#...#.....#.#.#\n#.#.#.###.#.#.#\n#.....#...#.#.#\n#.###.#.#.#.#.#\n#S..#.....#...#\n###############"
    D₄     [1_0 ¯1_0 0_1 0_¯1]
    End    ⊢⊚=@EData
    Costs  :∩▽⟜:(@#:Data).≡⊟⊙⟜(+1×1000¬≡/×=)+⟜:D₄∩¤°⊟
    :path(Costs|≍End⊙◌°⊟):[1_0]⊢⊚=@SData
    &p
    &p ⧻◴≡⊢/◇⊂