Day 6: Trash Compactor

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

you are viewing a single comment's thread
view the rest of the comments
[–] 6 points 10 months ago (4 children)

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β‚‚
  • source
  • hideshow 4 child comments