Advent of Code 2022 in APL & BQN Day 6!

Sdílet
Vložit
  • čas přidán 27. 06. 2024
  • In this video I cover the APL & BQN solutions to Problem A and B from Day 6 of Advent of Code 2022.
    AoC GitHub Repo: github.com/codereport/Advent-...
    APL Solution: github.com/codereport/Advent-...
    BQN Solution: github.com/codereport/Advent-...
    Problem Statement: adventofcode.com/2022/day/6
    How to Install APL RIDE: • How To Install APL
    Dyalog APL: www.dyalog.com/
    Dyalog RIDE: github.com/Dyalog/ride
    BQN: mlochbaum.github.io/BQN/
    BQNPAD: bqnpad.mechanize.systems/
    Chapters:
    0:00 Intro / Problem Description
    0:50 APL Solution
    5:15 BQN Solution
    Follow me on Github: github.com/codereport
    Follow me on Twitter: / code_report
    Follow me on LinkedIn: / codereport

Komentáře • 13

  • @winterrcore
    @winterrcore Před rokem +10

    What kind of sorcery did I just stumble upon :O

  • @rubenverg
    @rubenverg Před rokem +6

    You can also move the unique into the windowed reduce by using union, which discards all duplicates as it concatenates.

  • @oantolin
    @oantolin Před rokem +2

    In J I did this: [ + 1 i.~ (-:~.)\
    Instead of an n-wise reduce, J has the more general infixes operator which applies an arbitrary function (not necessarily a reduction) to all windows of a given length. Here I apply the function (-:~.) which checks if the widow is equal to its deduplication.

  • @aslpuppy1026
    @aslpuppy1026 Před 9 měsíci

    Can someone please explain if there is a way to clear the screen on the RIDE editor? I've been learning apl recently and find having hundreds of lines from previous sessions annoying.

  • @NikolajLepka
    @NikolajLepka Před rokem

    the way I did it, was by replacing the comma with the union to get the unique for each; not need to first group then unique when you can do it in one step

    • @NikolajLepka
      @NikolajLepka Před rokem +2

      Using your refactor, it looks like this: Solution ← {¯1+⍺+⍺⍳⍨≢¨⍺ ∪/⍵}

  • @gigog27
    @gigog27 Před 11 měsíci

    I am new to apl and I want to ask why is the composition ○ required for the tally?

  • @rubixdev
    @rubixdev Před rokem +1

    what happened to day 5?

    • @NikolajLepka
      @NikolajLepka Před rokem +1

      we don't talk about day 5

    • @betterbelle29
      @betterbelle29 Před rokem +2

      Day 5 is about 100x harder than this in an array language lol

  • @imanshul
    @imanshul Před rokem

    chatgpt suggested
    detect_marker_position ← { ⊂/≠⍵[1+⍳4] }
    it looks correct?

  • @abrudz
    @abrudz Před rokem +8

    The First of the Where is a bit wasteful, as it'll look for all the 1s rather than stopping when it finds the first 1 whereas 1⍳⍨ will stop immediately when a 1 is found. And as for code golf: ⊣-1-1⍳⍨∪/∊,/