Day 4: Ceres Search

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
    0
    ·
    3 months ago

    Uiua

    Just part1 for now as I need to walk the dog :-)

    Data$ MMMSXXMASM
             $ MSAMXMSMSA
             $ AMXSXMAAMM
             $ MSAMASMSMX
             $ XMASAMXAMM
             $ XXAMMXXAMA
             $ SMSMSASXSS
             $ SAXAMASAAA
             $ MAMMMXMMMM
             $ MXMXAXMASX
    Parse  ← ⊜∘⊸≠@\n
    GridParse Data
    Points ← [1_0 ¯1_0 0_1 0_¯1 1_1 1_¯1 ¯1_1 ¯1_¯1]
    ≡⍉⍉×⇡4¤Points             # Use Points to build sets of 4-offsets.
    ↯∞_2⇡△ Grid               # Get all starting points in grid.
    /+♭⊞(≍"XMAS"⬚@.⊡:Grid≡+¤) # Join the two into table, use to pick 4-elements, check, count
    
      • mykl@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        3 months ago

        The operators have all got ascii names you can type, and the formatter converts them to the symbols. It’s a bit odd but really worthwhile, as you get access to the powerful array handling functionality that made solving today’s challenges so much more straightforward than in other languages.