The Beauty of Rust
9:52
2 ай бұрын
Python vs C++ vs BQN vs APL
9:39
4 ай бұрын
BQN: Explicit to Tacit
11:09
4 ай бұрын
BQN vs Uiua vs Kap
12:11
6 ай бұрын
Python vs C++ vs BQN vs Uiua
11:08
J vs BQN vs APL vs Jello
13:50
8 ай бұрын
The Superpower of C++
7:27
8 ай бұрын
1 Problem, 4 C++'s
7:16
8 ай бұрын
State of Array Languages in 2024
4:45
Top Programming Languages of 2023!
3:50
BQN vs Uiua #3
5:29
Жыл бұрын
BQN vs C++
9:43
Жыл бұрын
More Functional C++?
9:48
Жыл бұрын
BQN vs Jelly
8:17
Жыл бұрын
APL vs BQN vs Uiua
18:09
Жыл бұрын
Python vs Uiua vs BQN
15:47
Жыл бұрын
BQN vs Uiua #2
13:02
Жыл бұрын
BQN vs Uiua
9:38
Жыл бұрын
Uiua! A New Array Language!
4:00
Жыл бұрын
Python vs BQN (1 Problem)
6:40
Жыл бұрын
Python + AI = Rust
7:48
Жыл бұрын
Пікірлер
@approbatory
@approbatory 6 күн бұрын
Episode 12 is AI. Connor r u serious???
@code_report
@code_report 6 күн бұрын
So are, 8, 9, 10 & 13. If ppl don't want to listen to those episodes that is totally fine
@anapaulamendozadiaz8890
@anapaulamendozadiaz8890 6 күн бұрын
As a lambda lover, I fricking love this!
@sho6501
@sho6501 7 күн бұрын
Can you make more videos like this? really enjoyed it!
@ruffianeo3418
@ruffianeo3418 8 күн бұрын
Every language wants to be a Lisp and every Lisp wants to be a Common Lisp... truth hurts ;) CL-USER> (defparameter *data* '((1 2 3) (5 5 5) (3 1 4))) CL-USER> (loop for x in (mapcar #'(lambda (line) (reduce #'+ line :initial-value 0)) *data*) maximizing x) 15 Or if you like to read the flow of data left to right, with a little help of my usual utilities: CL-USER> (pipeline (x *data*) (mapcar #'(lambda (line) (reduce #'+ line :initial-value 0)) x) (reduce #'max x :initial-value 0)) 15 Or if you like loops because all that reduce and map stuff is so unsimple... CL-USER> (loop for line in *data* maximizing (loop for x in line summing x)) 15
@nikiiv
@nikiiv 10 күн бұрын
```Elixir Enum.min_max([20,30,22,25]) |> then(fn {min, max} -> Integer.gcd(min, max) end) ``` Skips going over twice for the min and then for the max
@nikiiv
@nikiiv 10 күн бұрын
I'd submit this Elixir solution ```Elixir [[1,2,3],[5,5,5],[5,6,7]] |> Enum.max_by(&Enum.sum/1) |> Enum.sum() ``` or ```Elixir [[1,2,3],[5,5,5],[5,6,7]] |> Enum.map(&Enum.sum/1) |> Enum.max ``` It is funny how max_by is almost what is needed but not exactly..
@G11713
@G11713 11 күн бұрын
Since the C++ code is the only definition of "calculate", it is not a bug. Consequently, the unguarded range in Rust while elegant is wrong.
@pha1994
@pha1994 12 күн бұрын
I guess what people initially start to do is compress songs which are the biggest and see if the size goes under the drive capacity. But if you do this based on the size of the biggest to smallest song then you *may* have to compress more songs than necessary. This is because it is possible for example that only two songs which provided "maximum amount of compression" was needed. But if you do it based on each song size, biggest to smallest song, you"may" end up with a higher count. So focus on compressing songs based on which ones provide the "maximum compression", which is basically what a-b represents, so as to minimize the number of songs that you need to compress.
@d69p-eix
@d69p-eix 13 күн бұрын
If one prefers compact syntax, one could produce the same functionality in cpp with -v+1 where v is an array, and across all your projects data structures with operator overloading in the base class, syntax really has nothing to do with the ideas of category theory
@0LoneTech
@0LoneTech 15 күн бұрын
I had this silly feeling it can't be necessary to write the scan twice. |(»+`){𝔽-𝔽⌾⌽} This was the first time I wanted a ⟜ variant of ⌾. Prior variants: {|-⟜⌽˝(»+`)˘≍⟜⌽𝕩} # both directions in one 2d array {|-⟜⌽○(»+`)⟜⌽˜𝕩} # ○ to scan both sides, but missing ⌾ And then there's the awfully assymetric reduce and scan variant: |(+´⊸--(»2×+`))
@Pylo904
@Pylo904 15 күн бұрын
*hits the head on keyboard while holding AltGr* “Extremely beautiful!”
@tomekk.1889
@tomekk.1889 16 күн бұрын
Wow this is some horribly written code
@KnakuanaRka
@KnakuanaRka 19 күн бұрын
TIL about that Counter and other stuff; that’s nice to know.
@davidzwitser
@davidzwitser 23 күн бұрын
His setup and organization is so cool. Love the implementation and love the LSP update!
@christbaumer
@christbaumer Ай бұрын
`calculate = sum . filter even .* enumFromTo`
@whydoineedausername1386
@whydoineedausername1386 Ай бұрын
Honestly a bit disappointed. It might still be BQN, but I was hoping for an array style solution as I was struggling with my own APL solution to part 2. (Then I realised that I literally just had to change an or to a plus so that's good now)
@compsciwins-p4d
@compsciwins-p4d Ай бұрын
Love your video. Great stuff😊
@rupertwh
@rupertwh Ай бұрын
That 'bug' in C code seemed more like a design choice to me. But anyway, the real and much more sinister bug in the C version lies in the '<='! Think about what happens when top==INT_MAX.
@rubenverg
@rubenverg Ай бұрын
what I wanted to say yesterday is I think you can remove the whole ×≠next? part and always do each on next since when it's empty it stays empty, might be wrong though
@code_report
@code_report Ай бұрын
You are correct again! 🙏 I have updated the code : ) and cleaned it up even more
@acquite
@acquite Ай бұрын
what happened to day 8 and 9..?
@code_report
@code_report Ай бұрын
I will probably make videos for them, just decided to may Day 10 out of order
@klipronhoward
@klipronhoward Ай бұрын
I want to give BQN a try one day because i can't imagine myself ever being able to write code like this.
@misterpopo3736
@misterpopo3736 Ай бұрын
vscode has an extension, you don't have to type the symbols, just the name of it
@klipronhoward
@klipronhoward Ай бұрын
Love your videos. I'm doing Advent of Code in Python and Javascript and I understand everything you are saying but none of your code. It's like I'm trying to read an Alien Language.
@code_report
@code_report Ай бұрын
Thanks to @rubenverg and Rampoina for helped clean up my solution! 🙏 Meant to mention at the top of the video but forgot
@pmcgee003
@pmcgee003 Ай бұрын
I had a bit of fun looking at the structure of the data. The book pages are basically nodes and the order rules are directed edges. So I wanted to pick a line of data, then restrict the rules down to just those nodes, and then look at the graph. I think it's interesting. See here at 4:20 and 6:20 (not BQN related). kzbin.info/www/bejne/qpyrkKN5Yr96fbM
@pmcgee003
@pmcgee003 Ай бұрын
Really? Really?? "That's a rotate"? Is there no getting away from this? 😀
@Ganerrr
@Ganerrr Ай бұрын
id love to stick my solutions in my own lang in the comments but youtube constantly eats them
@bzboii
@bzboii Ай бұрын
1:45 actually -90 deg turn
@gigog27
@gigog27 Ай бұрын
Rewatching some old videos, I think this is a pretty nice point-free solution in bqn. ×´⊸÷ It's also 4 characters, but instead of an identity it uses bqn's "before". This is a more bqn-way to do it, and it even allows it to be placed in an expression without parentheses: ×´⊸÷ n However, the apl-style solution with identity still works in bqn, but the parentheses are needed: (×´÷⊢) n
@rubenverg
@rubenverg Ай бұрын
I was really surprirsed when I saw people doing pure brute force like this and it actually ran in reasonable time
@foresthobo1166
@foresthobo1166 Ай бұрын
Still 2-3 orders of magnitude slower than the reverse algorithms. And that is for n in the teens.
@speedstyle.
@speedstyle. Ай бұрын
'beautiful' superquadratic solutions... it could be O(n)...
@aly-bocarcisse613
@aly-bocarcisse613 Ай бұрын
Can someone explain the delta trick to compute the new direction ? I did not get it.😊
@code_report
@code_report Ай бұрын
You always make a right turn. So dx is a list of 4 x y deltas of the offsets to move your position either up, right, ,down or left (in that order). Dir (direction) is used to index into that, and whenever you need to make a turn you just +1 to dir (and also mod 4 to reset to 0).
@krccmsitp2884
@krccmsitp2884 Ай бұрын
Well, BQN looks... interesting... ;-)
@GermanLc
@GermanLc Ай бұрын
thats cheating
@toomuchdeeznut
@toomuchdeeznut Ай бұрын
For part 2, instead of testing with every non wall position, I test with only every position from the path I get from part 1, because if the additional wall is not on the original path, the guard won't hit the wall and change path anyway (I didn't use BQN but I did with Rust iterator)
@kevinmarques9334
@kevinmarques9334 Ай бұрын
I didn't quite understand your counter approach to check if the guard's path is in a loop... I figured that the obstacle only makes any difference if it's placed in the guard's path, so for each position in the guard's path I put a obstacle and recalculate the new route. My solution to check if an array of positions is in a loop I separated the last two positions and compared if it appeared in the tail of the list. It was a nightmare in JavaScript, but after some tries (3-5 min each) I managed to solve it
@relacibo
@relacibo Ай бұрын
I think, because a loop will run infinitly, the counter will be greater then the array size eventually. It's just very inefficient. I suspect the bqn solution, as elegant as it might be, will not run in any reasonable amount of time with the "real" problem input. Also because of the missed optimization opportunity, that you mentioned. Even in rust it took ~20-30 seconds for me.
@batlin
@batlin Ай бұрын
I stored each new (x,y,dir) triple in a set so a loop is discovered when the next state is already in the set. Together with the other optimisation you mentioned, only placing obstacles along the path generated in part 1, made it faster but still a bit slow in Picat (maybe 30s).
@aly-bocarcisse613
@aly-bocarcisse613 Ай бұрын
@@batlinyou just replied to my question on direction, thanks
@TankorSmash
@TankorSmash Ай бұрын
My BQN solution does something like this, where it calculates the previous tiles, and then goes through each one and adds an obstacle there and checks for tiles the guard has already been on. It takes like 3 minutes to run through the final solution though. Not nearly as elegant by a long shot
@kedarshinde4216
@kedarshinde4216 Ай бұрын
Every day I think, surely today's problem can't be solved in BQN, every day I am proven wrong
Ай бұрын
It's turing complete.
@Denny_Zmeen
@Denny_Zmeen Ай бұрын
I feel like you could use table (⌜) to simplify this last expression, no ? +´⥊∾(⌽∘⍉⍟(↕4)m)Xm⌜ 3‿3↕𝕩
@aly-bocarcisse613
@aly-bocarcisse613 Ай бұрын
I really enjoy your content in general but you literally converted me into array programing 😂. I’ll get started on this next year for sure. Can someone point me to the minute where it is checked that we have at most three digits ?
@code_report
@code_report Ай бұрын
You don't need to check that. Many solutions do but it is unnecessary.
@MegaPacoquinha
@MegaPacoquinha Ай бұрын
How long do you take on average to solve a AoC problem in bqn?
@code_report
@code_report Ай бұрын
Day 1 and 2 were both less <10 minutes. Day 3 was around 20 minutes I believe. Day 4 and 5 closer to an hour (was exploring different solutions). Day 6 (just A) was over an hour as my recursive solution stack overflowed - had to switch to a •_while_
@MegaPacoquinha
@MegaPacoquinha Ай бұрын
@code_report awesome, sometimes I get stuck for long in a question and I wonder how long does it take for others
@TankorSmash
@TankorSmash Ай бұрын
@@MegaPacoquinha It took me, a newbie to BQN, 8 hours for part 3, 5ish for part 4 and just 1.5 hours for part 5. I haven't uploaded any of them past the first ones yet, but it sounds like we're in the same boat in terms of going _real_ slow. I hope we both keep at it!
@stefano8936
@stefano8936 Ай бұрын
well if you say that 3.33 is more readable than the for loop I don't need to see further
@zin_the_one
@zin_the_one Ай бұрын
Been using this AoC as an opportunity to learn BQN. Didn't know about that pattern where all ordered pairs make an upper triangle. I spent 2 hours on implementing selection sort making things way more complicated xD Min ← (⊑∘(((∊⟜rules)˜⋈)◶⟨⌽,⊢⟩∘⋈)) sorted ← (⌽∾)∘(((((∊⟜(⋈Min´)˜)⊸⊔)∘⊑)∾(1⊸↓))⍟(≠∾))∘⋈¨updates sol ← (+´⊑∘((⌊(÷⟜2)∘≠)⊏⊢)¨)¨updates((≢¨)⊔⊢)sorted
@rubenverg
@rubenverg Ай бұрын
oh, I should clarify I stole the grade down table self thing from bqncrate, so it's presumably by Marshall! not my idea(:
@DanielAjoy
@DanielAjoy Ай бұрын
these two are equivalent: 0⌈ 1⌊ ¯2‿¯1‿0‿1‿2 0< ¯2‿¯1‿0‿1‿2
@davidzwitser
@davidzwitser Ай бұрын
Super cool 😁 fun to see how differently this can be approached. I was also inspired by dzaima's solution, I have a video of mine on my channel if that's interesting
@swedishpsychopath8795
@swedishpsychopath8795 Ай бұрын
What is the point of constanly having to compare rust to other languages? Can't it stand on its own legs and be a tool in the tool box as the other languages for us to pick up when we need exactly that ONE feature that attrackts you the most? Does it have to be just one swiss-army language in the tool-box? If so I prefer plain old ANSI-C (and java for OOP).
@aly-bocarcisse613
@aly-bocarcisse613 Ай бұрын
Seriously, this is great ?
@jakubgaecki5629
@jakubgaecki5629 Ай бұрын
Alternative (simpler?) solution to checking the X pattern in part 2: extract the diagonals into a 2x3 matrix, laminate it with its reverse, then check if exactly 2 rows are equal to 'MAS'.
@nunzioturtulici9636
@nunzioturtulici9636 Ай бұрын
As regards the safe function one can avoid doing the two checks 1≤x≤3 doing |x-2|≤1, in APL: (∧/(1≥∘|2-|)∧(1=≢∘∪∘×))(2-/⊢)
@boredstudent9468
@boredstudent9468 Ай бұрын
Where can I find more about that diagonals function, while not bqn I tried solving it declaratively but the diagonals broke me.
@code_report
@code_report Ай бұрын
Just wrote this up, hope it helps: mlochbaum.github.io/BQN/try.html#code=TG9nIOKGkCB74oCiU2hvdyDwnZWo4oC/8J2VqX0KCiJtIiBMb2cgbSDihpAgM+KAvzPipYrihpU5CkQg4oaQICgr4oycwrTihpXCqOKImOKJoiniirjiipQKCiMgU3RlcCBieSBTdGVwCiJyYW5nZSBvZiBlYWNoIGRpbWVuc3Rpb24iIExvZyDihpXCqOKJoiBtCiJvdXRlciBwcm9kIHN1bSIgTG9nICgr4oycwrTihpXCqOKImOKJoiltCiJncm91cCIg4oC/ICgoK+KMnMK04oaVwqjiiJjiiaIp4oq44oqUIG0p
@joepike1972
@joepike1972 Ай бұрын
I am just in my voyage of using APL where all of this was supper valuable. I had watched it before when the value went way over my head.