advent-of-code/2023/day16/day16.bqn
2024-11-12 21:46:18 +01:00

29 lines
1 KiB
BQN
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

grid>•FLines"input"
PBM•Import"../../bqn-graphics/pnm.bqn"
Mat{1˙¨(𝕩)(grid)0}
Sim{
Step{𝕨𝕊ivnv:
{𝕊1: ("img/out"(1•Fmt 1e4+i)".pnm")•file.Chars PBM ¬Mat ¨v ; 0}𝕨
nexts{´(0<(grid))𝕩}¨/{𝕊pd:
{
𝕊'.'·: p+d,d ;
𝕊'/'·: p-d,-d ;
𝕊'\'·: p+d,d ;
𝕊'|'1: p+d,d ;
𝕊'|'0: p+10,10,p-10,-10 ;
𝕊'-'0: p+d,d ;
𝕊'-'1: p+01,01,p-01,-01
}pgrid,|d
}¨nv
i+1,nvv,(¬nextsv)/nexts
}
¨1𝕨Step•_while_{02𝕩} 0𝕩
}
•Show 1 Sim00,01
mngrid
starts(10¨0¨m)(¯10¨(m-1)¨m)(01¨0¨n)(¯10¨(n-1)¨n)
•Show ´¨Sim¨starts