Best shuffle: Difference between revisions
J: simplify
(J: simplify) |
|||
Line 843:
<lang j>bestShuf =: verb define
yy=.
y C.~ (;yy) </.~ (i.#y) |~
)
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:
|