To my
>> Thus, the recent example with the Cryptarithm solver was a very
>> in-correct comparison, due to the unknown permutation generating
>> order.
Ralf Muschall <[EMAIL PROTECTED]> writes
> I did not study the problem in detail, but I think giving it
> an unsolvable puzzle would force it to try *all* permutations,
> thus eliminating the order problem.
Wise! Thank you.
(and how stupid i was)
Here it is:
--------------------------------------------------------------------
permutations :: [Z] -> [[Z]]
-- build the full permutation list given an ordered list
permutations [] = [[]]
permutations (j:js) = addOne $ permutations js
where
addOne [] = []
addOne (ks:pms) = (ao ks)++(addOne pms)
ao [] = [[j]]
ao (k:ks) = (j:k:ks):(map (k:) $ ao ks)
main = putStr $ shows (any ((==0).sum) $ permutations [0..9]) "\n"
--------------------------------------------------------------------
So the puzzle is to find the permutation with the zero sum.
Compilation: ghc-4.04 -c -fvia-C -O2 -O2-for-C test.hs
Now, could the people, please, reproduce this C++ program?
I have lost it. And i fear, can reach the letter archive only
tomorrow.
I propose to do the comparison first, on this example with the
permutation generating, then, on linear algebra - see my previous
letter.
And still, this next_permutation should be extracted from the C++
library, shown as the source C program, compiled from C and only then
run. Otherwise, the test may occur unfair.
------------------
Sergey Mechveliani
[EMAIL PROTECTED]