Best shuffle: Difference between revisions

J: simplify
(Undo revision 108107 by Fwend (talk) Now matches program.)
(J: simplify)
Line 843:
 
<lang j>bestShuf =: verb define
yy=. (\:#&>)@:(<@({~ ?~@#)@I.@=) y
y C.~ (;yy) </.~ (i.#y) |~ #>{./#@> yy
)
 
Line 853:
</lang>
 
yy is a (a list of) boxes of (lists of) indices where all characters selected by indices in a box are the same, and where the first box is the biggest box (contains the most indices. The phrase <code>({~ ?~@#)</code> shuffles the indices going into each box which makes the (deterministic) rotate which follows produce differing results sometimes (but only when that is possible).
 
Example:
6,962

edits