Producing permutations, part seven

Last time on FAIC I generated a “random” permutation of a deck of cards and gave you the first five cards, and challenged you to determine what the next five cards were. David Poeschl (of the Roslyn team!) was the first to get a possible order and, with the additional hint that the sixth card was the three of hearts, Joel Rondeau found the correct solution, which is below. Both used brute-force algorithms.

Continue reading

Producing permutations, part six

Last time in this series I presented an algorithm for generating a random number, and the time before I presented an algorithm that turns such a number into a permutation, so we can put them together to make an algorithm that returns a random permutation:

static Permutation RandomPermutation(int size, Random random)
  return Permutation.NthPermutation(size, RandomFactoradic(size, random));

Is this actually a correct algorithm for generating a random permutation? Give it some thought.

Continue reading

Mmm, curry

dnc-mayI’m back from a short but productive trip to beautiful San Francisco only to discover that the May-June issue of Dot Net Curry magazine in my inbox apparently has me on the cover. [1. Fortunately I did know about it ahead of time.]

It’s free, it’s online, but you have to “subscribe” to read it. Check it out!

Next time on FAIC: More on random permutations.

Photo by my colleague Bob.