Select your language

"People will buy anything that's one to a customer."

This problem was submitted to me:

  FOUR
+ FIVE
______
  NINE

Each letter always represents the same digit.
You have to find the digits corresponding to the letters so that the result of the addition you get after substituting the letters with digits is also correct.

Each of the 8 letters must be associated with a different digit.

I've written a Prolog program that finds all the solutions:

four_plus_five.pl

"FOUR + FIVE" is free software (license: GNU GPL Version 3).

To run this program, you need a Prolog interpreter.
Linux users can install the "swi-prolog" package using the package manager.

To run the program (instructions for a Linux system, with a KDE environment):
- Using the file manager (Dolphin), browse to the folder where you saved the file "four_plus_five.pl".
- Right-click in an empty space (not on the file) > Actions > Open Terminal Here
- In the terminal (Konsole), type:

prolog -f four_plus_five.pl

Be patient... Prolog starts displaying the solutions...

Here are the 72 solutions.

If you wish to learn Prolog, a very special programming language, you may use this site:

Learn Prolog Now!