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.
Wow, yes, that is not the greatest algorithm description :).
My interpretation is they want you to do the following:
fannkuch(n) { int maxFlips = 0, printCount = 0; foreach permutation p of [1..n] { maxFlips = max(maxFlips, flipCount(p)); if (printCount++ < 30) printPermutation(p); } print(maxFlips); } flipCount(p) { int count = 0; while (p[0] != 1) { reverse(p, p + p[0]); count++; } return count; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With