# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1573: Sat, Sun, Mon, Tue

From New Scientist #2736, 28th November 2009 [link]

Four consecutive days are noted in the two multiplication sums shown above, where different letters stand for different digits, the same letter stands for the same digit, each dot can be any digit, and leading digits cannot be zero.

Assuming that a MONTH is exactly divisible by each of 28, 30 and 31, what is the numerical total of the two five-digit products?

[enigma1573]

### 2 responses to “Enigma 1573: Sat, Sun, Mon, Tue”

1. jimrandell 13 February 2012 at 5:20 pm

The following Python program runs in 130ms.

```from itertools import permutations
from enigma import concat, split, printf

d1 = set(range(10))

# determine a value for MONTH
for (M, O, N, T, H) in permutations(d1, 5):
MONTH = int(concat(M, O, N, T, H))
if MONTH % 31 or MONTH % 30 or MONTH % 28: continue

# now try MON x ?? = TUE??
MON = MONTH // 100
for m2 in range(10, 100):
p2 = str(MON * m2)
if len(p2) != 5: continue
(t, U, E, _, _) = split(p2, int)
if t != T: continue
d2 = d1.difference((M, O, N, T, H, U, E))
if len(d2) != 3: continue

# try SAT x ?? = SUN??
for (S, A) in permutations(d2, 2):
SAT = int(concat(S, A, T))
SUN = int(concat(S, U, N))
for m1 in range(10, 100):
p1 = SAT * m1
if len(str(p1)) != 5: continue
if p1 // 100 != SUN: continue

s = p1 + int(p2)
printf("{s} [MONTH={MONTH} {SAT}x{m1}={p1} {MON}x{m2}={p2}]")
```

Solution: The sum of the products is 59136.

2. Hugh Casement 14 March 2016 at 9:49 am

The LCM of 28, 30, and 31 is 13020.  If MONTH is to have five different digits it must be 78120, so MON = 781.  We multiply that by a number between 26 and 38 to get a 5-digit product starting with T = 2.  SAT and SUN are at least 342; SAT ends in 2 and must be multiplied by at least 77 (probably more) to obtain a 5-digit number starting with the same digit (and having 1 as its third).  Furthermore, the second digit of each product is the same.  That narrows the search somewhat.