That looks like the right result.

Henry Rich


On 2/24/2016 11:20 AM, Brian Schott wrote:
Not FAST, but is this correct?

    H =. 1e6
    L =. _1
    D =: H, H, 1, H, 5, H, 8, H, 11, L, L, H, H, 20,3
    P =: 1, 1, 1, 2, 4, 2, 1, 1,  1, 1, 1, 1, 2, 1, 2

    proc=: dyad define
P=. x
D=. y
while. +./mask=.(L~:H,}:D)*.D>D<.P+H,}:D do.
D=. mask{"0 1|: D,:P+H,}:D
end.
D
)
    D,:P proc D
1000000 1000000 1 1000000 5 1000000 8 1000000 11 _1 _1 1000000 1000000 20 3
1000000 1000000 1       3 5       7 8       9 10 _1 _1 1000000 1000000 20 3
    D~:P proc D
0 0 0 1 0 1 0 1 1 0 0 0 0 0 0
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to