2024 day 17 part 1

This commit is contained in:
Dimitri Lozeve 2024-12-17 17:57:41 +01:00
parent 998d695685
commit 11fd8cbb02
3 changed files with 28 additions and 0 deletions

18
2024/day17/day17.bqn Normal file
View file

@ -0,0 +1,18 @@
in•FLines"input"
abc•ParseFloat¨12¨3in
Split((-˜+`׬)=)
p•ParseFloat¨','Split 9¯1in
Combo{𝕩(4)𝕨}
Step{
0n𝕊rabco: r+2,a÷ 2 abc Combo n,b,c,o;
1n𝕊rabco: r+2,a,b 32•bit._xor n,c,o;
2n𝕊rabco: r+2,a,8 | abc Combo n,c,o;
3n𝕊r0bco: r+2,a,b,c,o;
3n𝕊rabco: n,a,b,c,o;
4n𝕊rabco: r+2,a,b 32•bit._xor c,c,o;
5n𝕊rabco: r+2,a,b,c,o8| abc Combo n;
6n𝕊rabco: r+2,a,a÷ 2 abc Combo n,c,o;
7n𝕊rabco: r+2,a,b,a÷ 2 abc Combo n,o
}
Run{p𝕊abc: {(2(𝕩)p)Step 𝕩}•_while_{(𝕩)<p}0abc}
•Out 1(','•Fmt)¨¯1p Run abc

5
2024/day17/input Normal file
View file

@ -0,0 +1,5 @@
Register A: 24847151
Register B: 0
Register C: 0
Program: 2,4,1,5,7,5,1,6,0,3,4,0,5,5,3,0

5
2024/day17/test Normal file
View file

@ -0,0 +1,5 @@
Register A: 729
Register B: 0
Register C: 0
Program: 0,1,5,4,3,0