Skip to content

Sunday Times Teaser 3048 – Nero Scrag from Carregnos

by BRG on February 20, 2021

by Stephen Hogg

Published Sunday February 21 2021 (link)

Our holiday rep, Nero, explained that in Carregnos an eight-digit total of car registrations results from combinations of three Greek capital letters after four numerals (eg 1234 ΩΘΦ), because some letters of the 24-letter alphabet and some numerals (including zero) are not permitted.

For his own “cherished” registration the number tetrad is the rank order of the letter triad within a list of all permitted letter triads ordered alphabetically. Furthermore, all permitted numeral tetrads can form such “cherished” registrations, but fewer than half of the permitted letter triads can.

Nero asked me to guess the numbers of permitted letters and numerals. He told me that I was right and wrong respectively, but then I deduced the permitted numerals.

List these numerals in ascending order

From → Uncategorized

13 Comments Leave one →
  1. Brian Gladman permalink

    • Tony Smith permalink

      Brian
      The Teaser does not state that the tourist did any analysis before his 2 initial guesses.

      It is conceivable that there are numbers of permitted letters which allow exactly one possible number of permitted digits.

      The tourist could have guessed such a number of permitted letters and an incorrect number of permitted digits. Once he knew the correct number of permitted letters he could then deduce the correct number of permitted digits, and maybe the actual digits.

      I suspect that some or all of the programs here do not rule out this possibility.

      • Brian Gladman permalink

        Hi Tony,

        When we do a manual analysis of the situation in which the tourist finds
        themselves, we obtain the following possibilities for L (the number of
        letters), D (the number of digits) and M (the maximum digit):

        L => (D, M) pairs
        20 [(6, 6), (6, 7), (7, 7)]
        21 [(6, 6), (6, 7), (6, 8), (7, 7), (7, 8), (8, 8)]
        22 [(6, 6), (6, 7), (6, 8), (6, 9), (7, 7), (7, 8), (7, 9), (8, 8), (8, 9)]

        So we know that the situation you postulate doesn’t exist.

        And, since the programs do the same analysis, they too will rule it out.

        • Tony Smith permalink

          It seems to me that my hypothetical number would survive the
          analysis up to line 36 of your program and fail at line 44.

          Obviously if there was a test before line 44 that each number
          of possible permitted letters gave at least 2 possible numbers
          of permitted digits we could be sure that there is, in fact,
          no hypothetical number. Of course the manual analysis shows
          that the test would be passed.

          Although, essentially, this Teaser only needs the solution to
          three inequalities applying to a small range of numbers, it is
          very interesting.

          • Brian Gladman permalink

            Sadly (or maybe not) simple programs don’t deal with
            hypothetical numbers, only concrete ones. The only
            numbers of letters that reach lines 39 and above are
            20, 21 and 22. This can be confirmed by inserting a
            print statement before line 36.

  2. Frits permalink

    The “fewer than half ” constraint is not needed to limit the solution.

  3. Erling Torkildsen permalink

    • Brian Gladman permalink

      @Erling

      I like your approach because, in contrast to my own and Frits’ solutions, you produce sets of permitted digits directly.

      But I think it goes slightly wrong because your rnks() subroutine (on line 18) only returns the first set of permitted digits it finds when it is necessary to consider all valid sets of permitted digits for each number of permitted letters.

      Here is a version that follows your approach but is modified to overcome this issue:

      • Erling Torkildsen permalink

        Tanks Brian,
        It is a treacherous encouragement to get the answer you expect to be the right one. It weakens the judgement.
        I do not right away see how my program fail, but I shall study your alternative to find out.

        • Erling Torkildsen permalink

          I now realize what Brian’s disapproval is about. When restricted to cases with two alternatives (len(S) == 2) my dict S above is {20: [(1, 2, 3, 4, 5, 6), (1, 2, 3, 4, 5, 6, 7)]}. While those values contain information to pick the answer, they are not answer-alternatives in themselves. To use the one that only indirectly is, to display the answer, is ‘opportunistic’ and not proper programming.

          I also realize that itertools product function is a better alternative for producing all the 4-digit numbers than my nested loops. But I have not yet grasped in detail what goes on in the rather compact way that L2NM is built.

          • Brian Gladman permalink

            Yes, my apologies for line 25, which is beyond reasonable. Here is is done in a sane way:

      • Frits permalink

        Although Erling said he tried to use a a minimum of ‘analytics’ using “product” in lines 18-19 seems to be overkill as we only have to check that the highest possible number (highest digit in z * 1111) is less equal to L ** 3.

        • Brian Gladman permalink

          @Frits Yes, I am sure you are right. But my concern was getting it to work correctly so I left it alone except for those parts of it that I thought were bugs. However the test you mention is missing from lines 10-11 so this is a bug I should have noticed!

          NOTE: I owe Erling an apology since the omission of the constraint you mention is NOT a bug. The whole point of Erling’s code it that he doesn’t need to include this constraint because he explicitly generates and counts all valid sets of of digits. As you say, it is a very slow approach when compared with others but it nice to see a different approach being used, which is why I wanted to see it published in a corrected form.

Leave a Reply

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

Subscribe to this comment feed via RSS