Teaser 3246: Power Rearrangers – “Morphing times”
From The Sunday Times, 8th December 2024 [link] [link]
Superhero classmates Ann, Ben and Col were Power Rearrangers with birthdays on three consecutive days in the same month. Using “morphing times” super-fast mental arithmetic, each raised that month number to the power of their own birthday number (e.g., June 2nd gives 36). Correctly calculated, the three values’ rightmost digits differed. In descending order, as a three-figure value, these digits made a multiple of the month number, but in ascending order, did not.
A new Power Rearranger recruit, Dee, joined the class. Her birthday was earlier, but the aforementioned statements also applied to Dee, Ann and Ben. Dee also raised her birthday number to the power of the month number. Curiously, this gave the same rightmost digit as when she did the former calculation.
Give Dee’s birthday as dd/mm (e.g. 31/01).
Apologies for the delay in posting this puzzle – we’ve just had a 19 hour power outage.
[teaser3246]


Jim Randell 9:43 am on 8 December 2024 Permalink |
This Python program runs in 67ms. (Internal runtime is 378µs).
from enigma import (irange, tuples, seq_all_different, nconcat, rev, printf) # check a sequence of digits def check(m, ds): # they are all different if not seq_all_different(ds): return False # in descending order give a multiple of the month ds = sorted(ds, reverse=1) if nconcat(ds) % m > 0: return False # but not in ascending order if nconcat(rev(ds)) % m == 0: return False # looks good return True # number of days in each month mlen = dict(enumerate([31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], start=1)) # consider possible months for (m, n) in mlen.items(): # (day, digit) pairs for the month vs = ((d, pow(m, d, 10)) for d in irange(1, n)) # consider four consecutive (day, digit) in some month for ((D, dD), (A, dA), (B, dB), (C, dC)) in tuples(vs, 4): # check D's digit is the same as day^month if not (dD == pow(D, m, 10)): continue # check (A, B, C) and (D, A, B) if not (check(m, [dA, dB, dC]) and check(m, [dD, dA, dB])): continue # output solution printf("A={A} B={B} C={C} D={D} m={m} -> ds={ds}", ds=[dA, dB, dC, dD])Solution: Dee’s birthday is: 13/07.
So:
And:
LikeLike
ruudvanderham 2:54 pm on 9 December 2024 Permalink |
from calendar import monthrange import istr for month in range(1, 13): for d in range(1, monthrange(2024, month)[1] - 3 + 1): for dis in (0, 1): last_three = {str(month ** (d + dis + i))[-1] for i in range(3)} ascending = "".join(sorted(last_three)) descending = "".join(sorted(last_three, reverse=True)) if not (len(last_three) == 3 and istr.is_divisible_by(descending, month) and not istr.is_divisible_by(ascending, month)): break else: if str(month**d)[-1] == str(d**month)[-1]: print(f"{d:02}/{month:02}")LikeLike