Read input:
0:"5.in"
("BFFFBFFRLR"
"FBBBFFBRRL"
...)Partially applied = (=[...]) applied to "R", same as "R"=...
=["FFBBBBBLRL"]"R"
0 0 0 0 0 0 0 0 1 0Map (') partially applied = to every character in "RB"
=["FFBBBBBLRL"]'"RB"
(0 0 0 0 0 0 0 0 1 0
0 0 1 1 1 1 1 0 0 0)Reduce (/) the result with max (|), which is equivalent to OR for binary vectors
|/=["FFBBBBBLRL"]'"RB"
0 0 1 1 1 1 1 0 1 0Make scalar from base-2 vector
2 _sv |/=["FFBBBBBLRL"]'"RB"
250For each (') line in input apply previous expression as anonymous function, {...} automatically makes available first three arguments as x,y and z
{2 _sv |/=[x]'"RB"}'0:"5.in"
549 462 167 ...Assign result to S
S:{2 _sv |/=[x]'"RB"}'0:"5.in"
549 462 167 ...Reduce ('/') S with max ('|')
|/S
955"Grade down" S, gives array of indices to S which sort it
<S
100 748 752 ...S indexed by (@) its grade down, i.e is sorted S
S@<S
71 72 73 74 ...Map - to each pair (':) in sorted S
{-':x}S@<S
1 1 1 ... 1 2 1 1 ...Find index of 2 (?2) in the result
{(-':x)?2}S@<S
497Index by it...
{x@(-':x)?2}S@<S
568And add one
1+{x@(-':x)?2}S@<S
569