Day 1: Secret Entrance

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
    7
    ·
    6 days ago

    Uiua

    Today’s lesson: Never think that scanning the first 100 lines of input will give you a good understanding of it.

    Part 2 is really messy and could probably be much simpler, but I couldn’t get the logic straight in my head otherwise.

    "L68 L30 R48 L5 R60 L55 L1 L99 R14 L82"
    ⊜⋕⊸≠@\s∧⍜⊡⋅@¯⊚⊸⌕"L"∧⍜⊡⋅@+⊚⊸⌕"R"
    P₁ ← ⧻⊚=0\(◿100+)⊂50
    P ← (
      ⊃(-×100×|/+)⌊÷100⌵⟜(⊸±) # Count and remove all over-rotations
      ⍉⊟↘¯1⊸(\(◿100+)⊂50)     # Take all positions and next moves.
      ▽⊸≡(≠0⊢)                # Ignore any starting from zero
      +/+↥⊃(<0|>100)≡/+       # Sum the pairs, check for passing zero.
    )
    P₂ ← +⊃P P₁
    ⊃(P₁|P₂)
    
    • mykl@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      6 days ago

      Just had a look at the Uiua Discord, and Part 2 can be simplified a little…

      "L68 L30 R48 L5 R60 L55 L1 L99 R14 L82"
      ⊜⋕⊸≠@\s∧⍜⊡⋅⊚⊸⌕"L"∧⍜⊡⋅@+⊚⊸⌕"R"
      P₁  ⧻⊚=0\(100+)50
      P₂  /+=0100\+▽⌵⟜±⊂50
      P₁ P₂
      

      Sometimes I could just cry.