# Sunday Times Teaser 3026 – Party Time

*by Graham Smithers*

#### Published Sunday September 20 2020 (link)

A four-digit number with different positive digits and with the number represented by its last two digits a multiple of the number represented by its first two digits, is called a PAR.

A pair of PARs is a PARTY if no digit is repeated and each PAR is a multiple of the missing positive digit.

I wrote down a PAR and challenged Sam to use it to make a PARTY. He was successful.

I then challenged Beth to use my PAR and the digits in Sam’s PAR to make a different PARTY. She too was successful.

What was my PAR?

9 Comments
Leave one →

Hi Erling,

I am puzzled by your range for PARs. Aren’t the lowest and highest PARs 1236 and 4896 giving the loop limits as range(1236, 4897)?

You can also simplify the end a bit as follows:

Thanks, Brian

I knew there would be a more intelligent way to solve the concluding part, but as the combinations were so few, I lined them all out. (I did try some alternatives but stumbled in ‘syntax errors’ and their likes.)

That it a truly beautiful code layout, John, well done!

Thanks Brian. I did use the Wing IDE PEP8 reformat facility. But I had done most of the work manually. I probably should have commented that 45 is the sum of 1…9 and that the first four digits of the permutation are used to make PAR1 and the second 4 to make PAR2 though this did seem obvious to me when I posted.

There is a slight fudge in the code in that each PARTY appears twice in the list, once as [PAR1, PAR2, digit] and once as [PAR2, PAR1, digit]. While it would be easy to weed out the duplicates, having them makes it easier to find and print the solution in the hypothetical case where the permutations function produces the permutations in a different order. In any case the list of PARTYs is quite short.

Hi GeoffR,

You can also use the fact that digit ‘i’ can’t be five (abcd and efgh can’t both end on a zero).