2024 day 13

This commit is contained in:
Dimitri Lozeve 2024-12-13 20:40:21 +01:00
parent bea330905c
commit e479454d81
3 changed files with 1314 additions and 0 deletions

20
2024/day13/day13.bqn Normal file
View file

@ -0,0 +1,20 @@
lf,Split•Import"../bqn-libs/strings.bqn"
in>•ParseFloat¨¨¨2¨¨¨", "Split¨¨1¨¨": "Split¨¨lfSplit¨(lflf)Split ¯1•FChars"input"
Solve{offset𝕊xaya,xbyb,xpyp:
xpyp+offset
nanb{
# A and B are collinear, we should find the optimal solution,
# but I didn't need it for my input
𝕊0: 00;
# General case
nb((xp×ya)-yp×xa)÷𝕩
na(xp-nb×xb)÷xa
# Check that solution is integer
{´=𝕩 ? 𝕩 ; 00}nanb
}(xb×ya)-yb×xa
}
•Show +´+˝31ע0Solve˘in
•Show +´+˝31ע10000000000000Solve˘in

1279
2024/day13/input Normal file

File diff suppressed because it is too large Load diff

15
2024/day13/test Normal file
View file

@ -0,0 +1,15 @@
Button A: X+94, Y+34
Button B: X+22, Y+67
Prize: X=8400, Y=5400
Button A: X+26, Y+66
Button B: X+67, Y+21
Prize: X=12748, Y=12176
Button A: X+17, Y+86
Button B: X+84, Y+37
Prize: X=7870, Y=6450
Button A: X+69, Y+23
Button B: X+27, Y+71
Prize: X=18641, Y=10279