Quest 5: Fishbone Order

  • 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

Link to participate: https://everybody.codes/

  • mykl@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    4 days ago

    Uiua

    [Works on test data, but fails on Part 3 live data: my checksum is “Correct length and correct first character”. Posting for the record while I think about it more.] Turned out to be trailing zeros.

    F ← (
      ↘1⊙[0_0_0] # Create empty row
      ∧(
        ◡≡([⊃(↧⊃(=0⊢◌|>⊙⊡₁)|=0⊡₁◌|↧⊃(=0⊣◌|<⊙⊡₁))]) # Will it fit in each row?
        ⊟⊙(⊢⊚)⟜⊡⊢⊚⊸≡/↥                             # Find first non-zero row and col.
        (⍜⊡⋅∘)⊙⊃⋅∘∘                                # insert
        ⍥(˜⊂0_0_0)¬≍0_0_0⊸⊣                        # Add padding row back
      )
      ↘¯1
    )
    S     ← ⋕/$"__"⊡1⍉
    Part₁ ← S F
    Part₂ ← -⊃/↧/↥≡(S F)
    
    Part₃ ← (
      ⬚0⊸≡(⊂⊃(S|≡(°⊥₁₀▽⊸>₀⇌))F) # All sword stats
      ≡⊂⊙(⊢⍉)             # Append sword IDs
      ⊏⊸⍖                 # Sort
      /+×+1°⊏≡⊣           # Checksum
    )
    
    Part₁ [58 5 3 7 8 9 10 4 5 7 8 8]
    Part₂ [[2 7 9 9 3 8 3 8 8 6 8] [5 2 9 3 8 3 9 5 2 1 4]]
    Part₃ [[1 7 1 9 1 6 9 8 3 7 2]
           [2 7 1 9 1 6 9 8 3 7 2]]