The Maple help contains a nice example of a puzzle solver named alphametic,  see  ?Iterator,Permute.
The goal is to determine the distinct digits represented by letters which satisfy a given  equation. The provided solved example is:
alphametic("maple*sim = modelica + model");
        "16540*781 = 12904836 + 12904"
i.e.  m=1, a=6, p=5 etc.

It's worth studying the program (written as a module) because it includes a few useful techniques.
I would suggest the following exercise for a Maple (young) programmer.

1.  When solving the "classical" puzzle  "FORTY+TEN+TEN=SIXTY", instead of the correct answer "29786+850+850=31486",   you will see
"2978Y+850+850=3148Y".
Try to find what's going on and correct the code.

2. The solutions given by alphametic include numbers beginning with a zero.
Execute e.g. alphametic("send+more=money").
Modify the code to produce only standard numbers.

 


Please Wait...