1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| f<< /aoc/dmath.fs
: Time: noop ; : Distance: noop ;
f<< /aoc/input
create distances , , , , create times , , , ,
: above ( t d -- n ) \ distance: double
>r >r >r 0 >r V3
for i V3 i - um* V2 V1 d< not if to1+ V4 then next V4 2rdrop 2rdrop ;
: solvea times distances 4 for @+ >r swap @+ >r
swap r> r> 0 above rot> next 2drop * * * ;
: solveb
0 >r 4 for i 1- cells times + @ V1 100 * + to V1 next
0 0 >r >r 4 for i 1- cells distances + @ >r V2 V3
10000 1 m*/ swap r> + to V2 to V3 next 2rdrop rdrop
V1 V2 V3 above ;
solvea . nl>
\ slow (takes ~5min on make pcrun)
solveb . nl>
|