Yes, well I wrote it in a hurry and I've never done a shuffle algorithm before (my other program does random "selections", which is slightly different), so that was a brute force attempt!


Hey, at least your code was correct! That's a lot better than many attempts. Just for reference, a good shuffle algorithm looks something like this:


/* Shuffle x[1..n] in place */
for i=n downto 2
let j be uniform random from range [1..i]
swap x[i] and x[j]


--John