2024 day 17 part 1
This commit is contained in:
parent
998d695685
commit
11fd8cbb02
3 changed files with 28 additions and 0 deletions
18
2024/day17/day17.bqn
Normal file
18
2024/day17/day17.bqn
Normal file
|
@ -0,0 +1,18 @@
|
|||
in←•FLines"input"
|
||||
a‿b‿c←•ParseFloat¨12⊸↓¨3↑in
|
||||
Split←((⊢-˜+`׬)∘=⊔⊢)
|
||||
p←•ParseFloat¨','Split 9↓¯1⊸⊑in
|
||||
Combo←{𝕩⊑(↕4)∾𝕨}
|
||||
Step←{
|
||||
0‿n𝕊r‿a‿b‿c‿o: ⟨r+2,⌊a÷ 2⋆ a‿b‿c Combo n,b,c,o⟩;
|
||||
1‿n𝕊r‿a‿b‿c‿o: ⟨r+2,a,⊑b 32•bit._xor ⟨n⟩,c,o⟩;
|
||||
2‿n𝕊r‿a‿b‿c‿o: ⟨r+2,a,8 | a‿b‿c Combo n,c,o⟩;
|
||||
3‿n𝕊r‿0‿b‿c‿o: ⟨r+2,a,b,c,o⟩;
|
||||
3‿n𝕊r‿a‿b‿c‿o: ⟨n,a,b,c,o⟩;
|
||||
4‿n𝕊r‿a‿b‿c‿o: ⟨r+2,a,⊑b 32•bit._xor ⟨c⟩,c,o⟩;
|
||||
5‿n𝕊r‿a‿b‿c‿o: ⟨r+2,a,b,c,o∾8| a‿b‿c Combo n⟩;
|
||||
6‿n𝕊r‿a‿b‿c‿o: ⟨r+2,a,⌊a÷ 2⋆ a‿b‿c Combo n,c,o⟩;
|
||||
7‿n𝕊r‿a‿b‿c‿o: ⟨r+2,a,b,⌊a÷ 2⋆ a‿b‿c Combo n,o⟩
|
||||
}
|
||||
Run←{p𝕊a‿b‿c: {(2↑(⊑𝕩)↓p)Step 𝕩}•_while_{(⊑𝕩)<≠p}0‿a‿b‿c‿⟨⟩}
|
||||
•Out 1↓∾(','∾•Fmt)¨¯1⊑p Run a‿b‿c
|
5
2024/day17/input
Normal file
5
2024/day17/input
Normal 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
5
2024/day17/test
Normal file
|
@ -0,0 +1,5 @@
|
|||
Register A: 729
|
||||
Register B: 0
|
||||
Register C: 0
|
||||
|
||||
Program: 0,1,5,4,3,0
|
Loading…
Add table
Add a link
Reference in a new issue