Day 6: Trash Compactor

Megathread guidelines

FAQ

  • skissue
    link
    fedilink
    English
    arrow-up
    6
    ·
    3 months ago

    Uiua

    I’m new to Uiua, so probably not the best way to express the solution!

    ParseRows ← (
      ⊜∘⊸≠@\n
      ⍜⇌°⊂ # Get the row of operations.
    )
    ParseOperations ← ⊜⊢⊸≠@\s
    SumCalculations ← (
      ≡(
        ⍣(◇/×°@*
        | ◇/+°@+
        )
      )
      /+
    )
    
    Part₁ ← (
      ParseRows
      ⊓(ParseOperations
      | ⍉ ≡(⊜⋕⊸≠@\s) # Parse columns.
      )
      SumCalculations
    )
    
    Part₂ ← (
      ParseRows
      ⊓(ParseOperations
      | ⊜(□≡(⋕▽⊸≠@\s)) ≡/↥⊸≠@\s⍉ # Parse numbers.
      )
      SumCalculations
    )
    
    &fras "6.txt"
    ⊃Part₁ Part₂
    
    • mykl@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      3 months ago

      Looks good. I like how you managed to use the same structure for Parts 1 and 2; that’s more than I did. And yours is faster than mine too.

    • Quant
      link
      fedilink
      arrow-up
      2
      ·
      3 months ago

      One of us! One of us!

      Nice use of the inversion, I always forget that’s a thing