Ah, I've been especially curious about your solution of part B, because I've ended up with the same solution as yours which is O(N^2), but I felt like there could be linear solution to this... something along the lines of calculating array of deltas of deltas and counting the number of such deltas that can be used to fix bad places - I hoped that you would solve part b in some way like this since I wasn't able to fully elaborate such solution. Great video anyway!
You can remove the paren around the left tine of the AND-fork. Also, you can combine the NOT with the EqualTo into a NotEqualTo. Instead of Enclosing the major cells, you should be able to do the replicate on major cells as all results will have same length. You can even compose Safe with the replicate.
The last two definitely worked and are very nice clean ups ❤ The first one I think I already did after the video : ) github.com/codereport/bqn-code/blob/main/aoc/2024/day02.bqn
I'm curious about the memory usage of a solution like this. When I was solving part 2 in Clojure I relied on its lazy sequences to stop generating new permutations once a safe entry was found. With an array language it seems like you're making massive matrices of every possible permutation which would be wasteful. Are there internal optimizations to avoid unnecessary work? Admittedly the input for AoC is never big enough that this would be an issue, but how well would this scale to 10K-100K lines of input?
•Show ⌈´≠¨ Parse input shows 8 for my input, which means the longest row in the test input is 8 and that means you are only creating maximum 8 masks - which is pretty trivial. It isn't the number of rows that would benefit from lazy mask generation, it is really long individual rows. If the rows were really long, this solution might suffer but BQN is really fast (I have benchmarked it ~2500x faster than Python at times). If it was slow, you could just implement a lazy recursive algorithm.
How legible are these when you read other people's code? I don't know BQN and it sounds like a nightmare to figure out what these functions are supposed to do unless you comment them (none of the self-documenting variable names and all that which you can get in more verbose languages)
For those of us that are new to UIUA and are learning UIUA due to your videos, would you consider also doing AoC 2024 in UIUA?... kinda like teaching us noobs? Thank you for the consideration. :-)
I'm very new to Uiua. I obviously got here through code_report but I usually only manage to do part 1 of each day. Here's my Uiua solution for day 2: PartOne ← /+×≡/××≤3:≥1.⌵⊙↥:≡/×0.≡≡/-≡◫2 There no way this is the best solution, but it's my solution.
🎵Have yourself unary little Christmas 🎵
Thanks so much, each solution takes me hours. Hopefully Array programming will get easier sometimes soon.
Thanks to your APL videos, i did a similar solution on Part 2 except in APL.
Was waiting for this to drop after watching your Day 1 video
wake up babe, new BQN video dropped
Cool, my solution (in Python) used the sorted and reverse sorted trick you mention here
Ah, I've been especially curious about your solution of part B, because I've ended up with the same solution as yours which is O(N^2), but I felt like there could be linear solution to this... something along the lines of calculating array of deltas of deltas and counting the number of such deltas that can be used to fix bad places - I hoped that you would solve part b in some way like this since I wasn't able to fully elaborate such solution. Great video anyway!
You can remove the paren around the left tine of the AND-fork. Also, you can combine the NOT with the EqualTo into a NotEqualTo. Instead of Enclosing the major cells, you should be able to do the replicate on major cells as all results will have same length. You can even compose Safe with the replicate.
The last two definitely worked and are very nice clean ups ❤ The first one I think I already did after the video : ) github.com/codereport/bqn-code/blob/main/aoc/2024/day02.bqn
I'm curious about the memory usage of a solution like this.
When I was solving part 2 in Clojure I relied on its lazy sequences to stop generating new permutations once a safe entry was found. With an array language it seems like you're making massive matrices of every possible permutation which would be wasteful. Are there internal optimizations to avoid unnecessary work?
Admittedly the input for AoC is never big enough that this would be an issue, but how well would this scale to 10K-100K lines of input?
•Show ⌈´≠¨ Parse input shows 8 for my input, which means the longest row in the test input is 8 and that means you are only creating maximum 8 masks - which is pretty trivial. It isn't the number of rows that would benefit from lazy mask generation, it is really long individual rows. If the rows were really long, this solution might suffer but BQN is really fast (I have benchmarked it ~2500x faster than Python at times). If it was slow, you could just implement a lazy recursive algorithm.
How legible are these when you read other people's code?
I don't know BQN and it sounds like a nightmare to figure out what these functions are supposed to do unless you comment them (none of the self-documenting variable names and all that which you can get in more verbose languages)
For those of us that are new to UIUA and are learning UIUA due to your videos, would you consider also doing AoC 2024 in UIUA?... kinda like teaching us noobs? Thank you for the consideration. :-)
I might make a a couple Uiua specific videos, or just add it as a bonus in one of the upcoming videos : )
I'm very new to Uiua. I obviously got here through code_report but I usually only manage to do part 1 of each day. Here's my Uiua solution for day 2: PartOne ← /+×≡/××≤3:≥1.⌵⊙↥:≡/×0.≡≡/-≡◫2
There no way this is the best solution, but it's my solution.
Is 'Deltas' longer than its expression?? Like
product ← ×/
it is silly.
I mentioned in the video the "actual" Deltas was different. This is the actual implementation:
_AdjMap ⇐ {¯1⊸↓𝔽1⊸↓}
Deltas ⇐ -˜ _AdjMap