Skip to content

Sunday Times Teaser 3048 – Nero Scrag from Carregnos

by Brian Gladman 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

9 Comments Leave one →
  1. Brian Gladman permalink

  2. Frits permalink

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

  3. Erling Torkildsen permalink

    • Brian Gladman permalink


      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