Quest 6: Mentorship Matrix

  • 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
    3
    ·
    21 days ago

    Uiua

    Straightforward until part3. I left the naive approach running while I put together the version below, but of course the better algorithm got there first.

    Prep ← (
      ⍉˜⊟°⊏≡□                # store char with index
      ⊕(⊟⊃(⊢⊢|□≡(°□⊣)))⊛⊸≡◇⊢ # group them
      ⍉↯∞_6⊏⍏⊸≡(°□⊢⊢)        # re-arrange
      ▽=1◿2°⊏                # drop labels, as we never used them...
    )
    /+/+⊞>∩°□°⊟⊢Prep "ABabACacBCbca"     # Part1
    /+≡(/+/+⊞>∩°□°⊟)Prep "ABabACacBCbca" # Part2
    
    # Note that the pattern repeats, so the only distinct values
    # are in the first run and last run. Everything in between
    # will be identical. Only works when distance < string length...
    ⟜Prep "AABCBABCABCabcabcABCCBAACBCa"
    Rep   ← 2
    Split ← [1 -2Rep 1] # multipliers for the three results for each profession.
    Dist  ← 10
    ≡(≡(⊟∩□)⊃(≡+⊙(¤°□⊢)|¤♭≡+⊙(¤°□⊣)))¤×⇡3⧻ # Create the start, middle, end set for each.
    /+≡(/+×Split≡(/+/+⊞(≤Dist⌵-)∩°□°⊟))