# The Formula of Love

With Valentine’s Day approaching I though I would give you a love related maths problem. I don’t know who originated it but it dates back a long time. In this puzzle, different letters represent different digits between 0 to 9. Find a unique solution to the following equation:

Show that there is no other possible solution.

Try working it our before reading my solution below.

Let’s start my writing it more usefully as:

Because we are dealing with a four digit number that when squared gives a seven digit number we can work out a maximum and minimum that follows the KISS format of K, I and S being different digits and the last two digits the same.

MINIMUM: 1022 and MAXIMUM: 3155

Thus K is either 1, 2 or 3.

This narrows down our search.

Now lets look at the last two digits of KISS (i.e. SS) and PASSION (i.e. ON). We know that:

so S when squared must lead to a result ending in ON which fulfils the condition above.

SS = 00 gives ON = 00 so no good.

SS = 11 gives ON = 21 so no good.

SS = 22 gives ON = 84 so 2 is a possible value of S

SS = 33 gives ON = 89 so 3 is a possible value of S

SS = 44 gives ON = 36 so 4 is a possible value of S

SS = 55 gives ON = 25 so no good.

SS = 66 gives ON = 56 so no good.

SS = 77 gives ON = 29 so 7 is a possible value of S

SS = 88 gives ON = 44 so no good.

SS = 99 gives ON = 01 so 9 is a possible value of S

Although we have narrowed down the possible values of K and S we have no easy way of determining I. Therefore we have to resort to brute force and systematically check values of KISS. 1022, 1322, 1422, etc.

This yields the solution:

In order to find make sure this is a unique solution we’d have to write a computer program that tested every possible value of KISS according to our conclusions above. This would most probably involve nested loops and some complex IF statements to determine that each letter represents a unique value and that I and S are the same in PASSION and KISS. If you take the time to do this please send me the code.

If you can think of a more elegant way of determining the solution or find an alternative please let me know.