Advent of Code 2024 in BQN Day 6!

  Рет қаралды 1,477

code_report

code_report

Күн бұрын

Пікірлер: 11
@kedarshinde4216
@kedarshinde4216 5 күн бұрын
Every day I think, surely today's problem can't be solved in BQN, every day I am proven wrong
5 күн бұрын
It's turing complete.
@kevinmarques9334
@kevinmarques9334 5 күн бұрын
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 5 күн бұрын
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 4 күн бұрын
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 4 күн бұрын
@@batlinyou just replied to my question on direction, thanks
@bzboii
@bzboii 3 күн бұрын
1:45 actually -90 deg turn
@aly-bocarcisse613
@aly-bocarcisse613 4 күн бұрын
Can someone explain the delta trick to compute the new direction ? I did not get it.😊
@code_report
@code_report 4 күн бұрын
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).
@GermanLc
@GermanLc 5 күн бұрын
thats cheating
Programming Is Cooked
9:30
ThePrimeTime
Рет қаралды 347 М.
Live Coding in BQN (bqn-format)
4:59:17
code_report
Рет қаралды 1 М.
Creative Justice at the Checkout: Bananas and Eggs Showdown #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 35 МЛН
Advent of Code 2024 in BQN Day 10!
5:16
code_report
Рет қаралды 549
Keynote: Advent of Code, Behind the Scenes - Eric Wastl
46:01
Day 6: Guard Gallivant | Advent of Code 2024
23:39
William Y. Feng
Рет қаралды 2,1 М.
Actually, Maybe There's Only 1 Game of Tic-Tac-Toe
11:58
Marc Evanstein / music․py
Рет қаралды 1,1 МЛН
Linus just made this run 2.6% faster in Linux
1:48
Machinely
Рет қаралды 13 М.
Coding Adventure: Rendering Text
1:10:54
Sebastian Lague
Рет қаралды 766 М.
Advent of Code 2024 in BQN Day 4!
16:58
code_report
Рет қаралды 1 М.
Reacting to Controversial Opinions of Software Engineers
9:18
Fireship
Рет қаралды 2,1 МЛН
Advent of Code 2024 in BQN Day 7!
9:46
code_report
Рет қаралды 742
10 weird algorithms
9:06
Fireship
Рет қаралды 1,3 МЛН