Skip to content

Sunday Times Teaser 3019 – William’s Prime

by Bill Scott

Published Sunday August 02 2020 (link)

William was searching for a number he could call his own. By consistently replacing digits with letters, he found a number represented by his name: WILLIAM.

He noticed that he could break WILLIAM down into three smaller numbers represented by WILL, I and AM, where WILL and AM are prime numbers.

He then calculated the product of the three numbers WILL, I and AM.

If I told you how many digits there are in the product, you would be able to determine the number represented by WILLIAM.

13 Comments Leave one →
  1. Brian Gladman permalink

    • Tony Smith permalink

      Hi Brian

      A=0 and W=0 should not be allowed because they would be leading zeros – the puzzle would have no solution if either was allowed.

      I assume your program rules them out but I do not know how. Does line 17 achieve this?

      There is no reason why I = 0 should be ruled out. I do not know whether the programs posted here allow it.

      Line 8 of GeoffR’s first program seems to rule out I = 0 but line 5 of his second program suggests that it allows it (that being the only way the product could consist of one digit).

      Line 11 of John Z’s program suggests that it does not allow I = 0.

      • Brian Gladman permalink

        Yes, line 17 ensures that A and W are not zero. My code allows I to be zero
        but, as you say, Geoff’s first program (and also John’s) wrongly prevent this.
        Geoff’s second program initially excluded I = 0, but was modified later to
        allow this.

        • John Z permalink

          I disagree on this one. I = 0 can be excluded from the start.

          From the Teaser statement:
          “If I told you how many digits there are in the product, you would be
          able to determine the number represented.”

          Let n = how many digits there are in the product

          The Teaser statement indicates that a product with n digits can only
          occur once. If I == 0 then there will be several WILL * I * AM = 0
          products with 1 digit. So I = 0 can safely be excluded.

          If L==0 then WILL is not prime and if M==0 AM is not prime. And as
          said above W and A can not be 0 because leading 0s are not allowed.

          • Brian Gladman permalink

            I = 0 is no different from I = 5 or 6. For each of these we
            have to ***show*** that the are multiple solutions. Just
            stating this is not good enough since your logic for
            removing I = 0 can b e applied equally well to I = 5 and 6.

  2. GeoffR permalink

  3. John Z permalink

  4. GeoffR permalink

    We can also show the product must be 1, 5, 6 or 7 digits long. So can identify the answer from the four lists for these digit lengths

    This also shows that there are 579 possible values for WILLIAM.

  5. Frits permalink

    • Brian Gladman permalink

      Hello Frits,

      Welcome to my site!

      I have fixed your post – for future reference the tags for posting code here are <pre> and </pre>.

      It doesn’t matter on such a short program but your construction for P2 is very inefficient. With a minor modification the program runs in 10ms rather than 470ms on my system:

  6. John Z permalink

    • Brian Gladman permalink

      Hi John,

      This version will print one line only on all platforms. Your original version was different:

      and this prints multiple empty lines in addition to the intended lines.

      In any event these constructions are poor alternatives to a simple loop:

      If you don’t like my alternative using zip, I can modify your code above to use this version.

      • John Z permalink

        Yes, I agree a looped print statement is not a good idea. I won’t use them in the future.

Leave a Reply

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

Subscribe to this comment feed via RSS