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