tags:

views:

135

answers:

2

I'm having trouble understanding the instructions of implementing Fannkuch. Instructions: http://www.haskell.org/haskellwiki/Shootout/Fannkuch

After step "Count the number of flips, here 5.", I am lost.

+2  A: 
Gary Linscott
Thanks Gary. I am understanding this now however I noticed that there appears to be a correct order of permutations that get printed. I'm trying to understand now why those specific 30 permutations are printed, and why in that order.
mudge
The specific permutation order doesn't really matter. That specific order is listing the permutations in lexicographical order from 'smallest' to 'largest'.That is generally how functions like next_permutation() in C++ would behave given a sorted list. Interesting article on this -> http://marknelson.us/2002/03/01/next-permutation/.
Gary Linscott
So the list of 30 permutations is just the results of the function to generate the first permutations? They are not completely in lexicographical order. The fourth and fifth permutations are out of lexicographical order.
mudge
Whoops, you are totally right. I only read the first few permutations. It looks like they have a well defined permutation order they want you to use, which is given in C or Lisp in the PS file on the site.A few of the given Haskell examples even have "this does not use the correct permutation order" :).
Gary Linscott
A: 

See the Benchmarks Game - Fannkuch

Requiring the first 30 permutations to be printed was just a simple way to limit the acceptable changes that could be made to the algorithm.

igouy