Skip to content

Sunday Times Teaser 2803 – Easy as ABC

by Danny Roth

Published: 12 June 2016 (link)

George and Martha have replaced the digits 0 to 9 by the letters A to J in some order. George then noted a neat product, namely:

    AB x CDE = FGHIJ

Then Martha noted a neat sum, namely

    AB + CD + EF + GH + IJ = CCC

What, in order, are the values of the letters A to J?

7 Comments Leave one →
  1. Brian Gladman permalink

  2. Brian Gladman permalink

    Here is a general solution for alphametics. It is very slow but it can be used to solve a set of alphametic equations such as those in this teaser.

    It provides an answer for this teaser:

    in 30 seconds which compares with 110 milliseconds for the program above.

    We can also use the AlphaSum solver to solve the addition sum and then use its results with the multiplication sum:

    which runs in 2.5 seconds. It is slower than solving the multiplication sum first because the addition sum has many more solutions than the multiplication sum.

  3. Here are two solutions that use the SubstitutedSum() solver from the library [ ].

    The first is short, but not very quick (as there are lots of solutions to the addition sum because the summands can appear in any order). It solves the addition sum and then checks the values also work in the multiplication sum.

    The second starts by solving the multiplication sum (which has fewer solutions), and checks if the values work in the addition sum. It’s a bit longer, but a lot quicker.

    • Brian Gladman permalink

      Hi Jim,

      I did not think of doing the teaser this way but I did contemplate adding a second array to my sum solver that contains the factors by which the corresponding values in the sum are multiplied.

      My first thought was that this would be a constant set on input but I contemplated converting the sum solver into a product solver by allowing this array to participate in the substitution process.

      But I then realised that a lot of substituted product teasers involve constraints on partial products so we would need a full scale product solver.

      Given you have a sum solver and a division solver in, this is a gap that I will leave you fill as I don’t much like alphametics anyway!

    • I’ve added a generic Alphametic solver to the library, which allows problems like this to be solved directly from the command line:

      On my machine this runs in 469ms, compared with 155ms for the second program I gave above.

      I’ve written an article showing how to use it to solve several similar puzzles in only a few seconds. It’s available at [ ].

  4. Arthur Vause permalink

    It is possible to combine the two equations into a single expression,
    ‘(AB*CDE == FGHIJ) & (AB + CD + EF + GH + IJ == CCC)’,
    then test the expression using Raymond Hettinger’s code.

  5. Naim Uygun permalink

Leave a Reply

Note: HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS