- Видео 63
- Просмотров 36 453
yernab
Добавлен 26 мар 2009
Advent of Code 2024 - Day 13 - Dyalog APL
Link to the transitive closure solution I mentioned: www.reddit.com/r/adventofcode/comments/1hcdnk0/2024_day_12_solutions/m1u432r/
Turns out this is actually a solution for day 12, not day 13! Sorry for that, that's what I get for trying to record these in the morning before coffee. :(
Turns out this is actually a solution for day 12, not day 13! Sorry for that, that's what I get for trying to record these in the morning before coffee. :(
Просмотров: 307
Видео
Advent of Code 2024 - Day 10 - Dyalog APL
Просмотров 26721 день назад
Advent of Code 2024 - Day 10 - Dyalog APL
Advent of Code 2024 - Day 5 - Dyalog APL
Просмотров 31421 день назад
Take two, sorry about the previous upload that only focused on a corner of my screen. :(
Data Science Puzzle in APL (D&D Sci.)
Просмотров 4043 месяца назад
Pleased to present almost 2 hours of me floundering around! D&D Sci Scenario Index: www.lesswrong.com/posts/6QfatwCcmuaDBNeDv/d-and-d-sci-scenario-index Potion scenario: www.lesswrong.com/posts/EC4R6FFjnsDz3cxcp/d-and-d-sci-alchemy-archmage-anachronos-and-the-supply-chain-1
Advent of Code 2023 - Day 9 - k/APL/!MATH!
Просмотров 424Год назад
Mathologer video, good explanation: ruclips.net/video/4AuV93LOPcE/видео.html
Advent of Code 2023 - Day 7 - Dyalog APL
Просмотров 371Год назад
Advent of Code 2023 - Day 7 - Dyalog APL
Advent of Code 2023 - Day 4 - Dyalog APL
Просмотров 578Год назад
Advent of Code 2023 - Day 4 - Dyalog APL
Advent of Code 2023 - Day 3 - Dyalog APL
Просмотров 728Год назад
Advent of Code 2023 - Day 3 - Dyalog APL
Advent of Code 2023 - Day 1 - Dyalog APL
Просмотров 1,8 тыс.Год назад
Advent of Code 2023 - Day 1 - Dyalog APL
Taking a look at ngn/k!
Просмотров 1 тыс.Год назад
ngn/k: codeberg.org/ngn/k xpqz book: xpqz.github.io/kbook/Introduction.html razetime book: github.com/razetime/ngn-k-tutorial/blob/main/01-intro.md
More Advent of Code in Uiua
Просмотров 5 тыс.Год назад
Problem description: adventofcode.com/2021/day/4 Take a look at Uiua! www.uiua.org/pad
Advent of Code 2020 - Day 7 - Dyalog APL
Просмотров 228Год назад
Advent of Code 2020 - Day 7 - Dyalog APL
Solving Rosalind problems with Dyalog APL
Просмотров 887Год назад
Solving Rosalind problems with Dyalog APL
Advent of Code 2022 - Day 8 - Dyalog APL
Просмотров 2582 года назад
Advent of Code 2022 - Day 8 - Dyalog APL
Advent of Code 2022 - Day 7 - Dyalog APL
Просмотров 3122 года назад
Advent of Code 2022 - Day 7 - Dyalog APL
Advent of Code 2022 - Day 6 - Dyalog APL
Просмотров 1262 года назад
Advent of Code 2022 - Day 6 - Dyalog APL
Advent of Code 2022 - Day 5 - Dyalog APL
Просмотров 2082 года назад
Advent of Code 2022 - Day 5 - Dyalog APL
Advent of Code 2022 - Day 4 - Dyalog APL
Просмотров 1732 года назад
Advent of Code 2022 - Day 4 - Dyalog APL
Advent of Code 2022 - Day 3 - Dyalog APL
Просмотров 2822 года назад
Advent of Code 2022 - Day 3 - Dyalog APL
Advent of Code 2022 - Day 2 - Dyalog APL
Просмотров 3482 года назад
Advent of Code 2022 - Day 2 - Dyalog APL
Advent of Code 2022 - Day 1 - Dyalog APL
Просмотров 8162 года назад
Advent of Code 2022 - Day 1 - Dyalog APL
Advent of Code 2021 - Dyalog APL - Day 15
Просмотров 1242 года назад
Advent of Code 2021 - Dyalog APL - Day 15
Advent of Code 2015 - Dyalog APL - Day 15
Просмотров 1822 года назад
Advent of Code 2015 - Dyalog APL - Day 15
Advent of Code 2021 - Dyalog APL - Day 22
Просмотров 1282 года назад
Advent of Code 2021 - Dyalog APL - Day 22
Advent of Code 2021 - Dyalog APL - Day 25
Просмотров 6682 года назад
Advent of Code 2021 - Dyalog APL - Day 25
Advent of Code 2021 - Dyalog APL - Day 9
Просмотров 762 года назад
Advent of Code 2021 - Dyalog APL - Day 9
Is there any resource you used to learn which graph algorithms translate to which matrix operations? I looked a bit on Google, but I don't think I know the right keywords
At 3:15 where you show dopandasreallyexist's solution, I think you showed the wrong one, that looks like it would be for day 12, not 13.
@@oantolin Yeaaaah, I mentioned that in the video description, dumb mistake :|
Great explanation of matrix path algorithms. It's looking like Advent of Linear Algebra this year!
My never-ending quest is to make every year a linear algebra year. ;)
glad to see you back :)
This is a mind-blowing solution to day 5 - had me out here sequentially reversing numbers like a fool
I’m glad to see you’re posting your solutions again. I really enjoy seeing the problem visually like this. Will have to come back later tho, I haven’t finished part two yet.
Looks cool, I'm wondering about how hard could be to debug complex code
🤯
For me on Linux I can hold shift and use the scroll wheel and it'll scroll just about everything horizontally. Even random text input fields will work with that key combo. I looked it up, and apparently it's the same combo on the Mac, so give that a try next time. Have you used APL for any jobs that you've done? What programming language do you use the most that's not an array processing language?
Hey, sorry for the late response! Nah I am purely an APL hobbyist, though some of the techniques/mindset have proved useful in my job. I’ve gotten paid to write code in a bunch of languages, but mostly C#/.NET
This is awesome, I never heard of D&D.sci before but will definitely check it out Just a couple tips for the beginning: You can use the (experimental) ]get user command to bring in the data directly from URL You can use ]rows on -fold to prevent the session flooding with long output More tips like this if you search "dyalog tips"
Ah I really am rusty - I had the wrong formulation towards the end of the video for the question "For each result, what's the percentage of occurrences where 2 or more required pairs were used?". This will work (with the bonus of not having any ugly outer products): r,⍪100×rpt{(+/÷≢)∨/4=+/⍺∧⍤1⍤1 2⊢⍵}¨⊂x⌿⍨4=+/x←,[1 2]∨⍤1⍤1 2⍨↑∧⌿¨rpt It shows that, as expected, "Mutagenic Ooze" has 2 or more required pairs 100% of the time, while "Acidic Slurry" has 0 (makes sense since it shouldn't have any required pairs at all, anyway).
This was incredible! I would love to see another D&D Sci one going. It was especially easy to follow at first when you were just trying stuff. Towards the end I was just along for the ride. I'm getting used to AoC in BQN and would love to see this approach used to solve stuff in it too. Thanks for uploading!
finally a new video! When will we see some more K? I'm learning it and your videos on it have been incredibly helpful!
yay, new video!
Great video! Please do more UIUA, love it!
Good coverage about APL in Rosalind problems, learned new ways to solve a problem.
Why do array based languages have to involve a bunch of symbols that my keyboard can't type? Are you all selling alternative keyboards or something? What are you doing?
Btw, an affine space is juste a set A (points) and a vector space V with a translation operation +: AxV->A such that for all a,b in A, there's a unique u in V such that a+v=b. So it's basically a set of points A which you can link together with vectors from V. Examples are: - euclidean plane and vectors - datetimes and durations - characters and ascii code difference - solutions to Ax= b and solutions to Ax=0
UIUA is amazing, but "recreating programming" when we already know the answer can feel like a boring teacher using slides in the classroom - it's not the most engaging method of teaching. The best use of Uiua/APL/BQN to solve problems is to tackle new challenges. We can even trim clips from videos after uploading them to RUclips.
Brilliant use of the mathematics and seeing how elegant it is to express in APL
Really impressive solution. I did part 2 as a constraint problem for a SAT solver and it took about 30 seconds to solve; wish I'd thought of this!
Great video, thanks for putting it out!
I found a clever piece of math too. You can express the next number in the sequence as a weighted sum of all the previous numbers. The weights follow binomial coefficients. This ended up being my solution, and part 2 I just reversed the input. I’m sure there is plenty of possible simplification in this. (-/⌽∘({⍵!⍨¯1+⍳⍵} ∘⍴×⊢))¨(⍎'¯'@('-'∘=))¨ ⊃ ⎕NGET 'input.txt' 1
Slight nitpicking point - in part 2, you can take advantage of APL's rank polymorphism to replace c=c by 1, thus simplifying your power formula as such : +/(1+m+.×⍨⊢)⍣≡1 Great solution, I learn a lot watching you solve these problems. Thanks a lot.
It's perhaps worth noting that because you're using these intermediate values as sort keys, you could have been "sloppier" in some of the results. Instead of the 10 encode of the 2 take of the sorted grouped counts, you could have used the mix of those sorted grouped counts (for part 2, I guess this would mean sorting each of them in descending order and taking the first each time). Instead of 2 drop of quadD for the digits, you could have used quadD,'TJQA'. I am not sure if this represents an improvement in code quality, but it was an option.
Thanks for sharing your APL solutions. My day 12 idea requires a technique I haven't found in apl, not sure it's even possible. Can you help ?
I'm new to APL example, what exactly technique are you trying?
@@sicko815 I'd like a way to memoize/cache a function efficiently, like what @cache does in python. Or more generally an efficient key-value data structure. I've found memo/cache from dfns, but I don't get the expected speedup. I might be doing something wrong. I now know I can create a hash array with 1500⌶ and build my own hashing function, but maybe there's a better way.
I finally got around to doing day 3. For part one I read the input into a matrix and added a border around the entire thing so I could go backwards or forwards in any direction by one space and not have to worry about where I was reading. The first part was easy, but life intruded and slowed me down. I doubt my solution is all that optimal either, but it works, so whatever. For part two, I made another matrix and stored the value of each number in every position it occupied, then scanned through a second time for each asterisk and where it touched two numbers. It took me far too long to think of that solution and it's even less optimal since I scan the input twice, but it works. I don't know if I'll be able to make time to work on any other days, but I'll give it a shot. I don't know what the deal is lately, but the amount of time I have to do anything fun is a dwindling supply.
Here's my verbose day 1 part 1: s←⊃⎕NGET'1.txt'1 n←{(⍵∊⎕D)/⍵}¨s d←{(⍎⊃⌽⍵)+10×⍎⊃⍵}¨n day1←+/d Just learning APL, and picked AoC as for my usual excuse to learn a new programming language, I was able to do the first part using the execute function ⍎ to eval the digit character only (after compressing them), and also converting digit characters to ten base with {(⍎⊃⌽⍵)+10×⍎⊃⍵}. Your solution has thought me a bunch of things I didn't yet read up on in detail. But the second part was way over my head so I gave up and came here to watch you. When I read the Find (⍷) function, I couldn't figure out how to make use of it, didn't think of the outer product and inner product trick. I'm wondering how much time did this take you to solve it? Once one is fluent with APL, does the process of figuring things out become quick?
So cool.
Will you do day 8? Thanks
complete gibberish how do i make money from this
How do you make money from breathing?
Yet again, making me feel dumb, since I used C for this one too and gave too much importance to the semicolons. Eventually I realized that they didn't matter and ignored them too. I honestly expected after day 1 that the second part would be challenging, but merely multiplying the numbers at the end didn't require any extra thinking. I'll definitely look at day 3 after I eat supper, I promise.
How did day 3 go?
@@yernab Sadly, I fell asleep after eating and forgot about it. But I was actually just about to look now.
Makes me feel kind of dumb because I wrote mine in C. I still haven't found the time to do day 3 and we're almost through with day 9. For day 1 I used a trie where the leaf nodes yielded the value and just constructed it in reverse for finding the last digit. I don't think tries get enough love but for strings they're often more efficient than a hash table.
I've indeed tried and +/,i + m + (m+.×m) + (m+.×m+.×m) + ... gives the correct result, but I'm struggling automating that with the power function (trying for fun), would you know how? or maybe a loop/recursion would be needed here?
(i+m+.×⊢)⍣≡i - if you factor this out (and make use of the fact that any matrix M times the identity matrix I is just M), you'll note that it expands to be the same as the terms you put above!
thanks 🙌🏻
That's an amazing solution, I'm learning APL through your videos, but I'm learning a lot about elegant problem solving too 💙
Really nice. I did a bit of playing with APL this week. I'd love to see a video on what you think of the different array language options out there, if you have the interest. I'm not sure which I should focus on.
Recommend just picking one and trying it! Lots of skills carry over and there’s a lot of primitive overlap between them. Dyalog APL and BQN have great documentation (Uiua’s is pretty good too).
I was getting stumped by all kinds of stupid errors and trying to think of combinations myself - went on reddit turns out you can substitute J with the most common card in each hand and re run part 1 for part 2
You probably have to explicitly handle JJJJJ in that case :)
Skipping 6 is fine, it's doable with any pocket calculator with a square root button
The code may break if one line ends with number while the next line starts with number. It seems not to be the case for all input lines. Maybe adding a "." before flatten the inputs would be a good precaution.
That’s a really elegant way to handle that case!
well done :)
do you have plans to do a solution in jelly?
I am impressed with this programming language. What APL can be used for? Can you do a game engine in APL, for example?
Of course, as soon as I finish recording I realize that tricky line can be significantly shortened... g:&/,/{(z 1+y'*'a)+a:,/f[y]'x}/[;m;t]@
Love your ngn/k solutions. Can we get more of them please
I like that this is in miliseconds and other solutions are in minutes.
Absolut mad. Array programming still looks like the functional programming equivalent for aliens to me. It's very interesting. Thanks for the video!
superb solution!
I just dropped in here and..WTF is all this symbols and language
As the title says, APL.
I'm really enjoying these videos and learning a lot about programming and math! Really appreciate it.
Glad to hear!
Can you show this in ngn/k please.