Teaser 3283: Die hard?
From The Sunday Times, 24th August 2025 [link] [link]
I have three identical standard dice (1 to 6 spots on each face, with 1 opposite 6, 2 opposite 5 and 3 opposite 4). I have placed them together in a row on a table and looked at the row from various sides. Regarding each face of a die as a digit (so that, for example, five spots would be regarded as a 5), I can read three 3-digit primes; one along the front of the row, one (the largest of the three) along the top of the row, and one along the back viewed from behind. Furthermore, the total number of spots on the 11 visible faces is also a prime.
What, in increasing order, are the three 3-digit primes?
[teaser3283]


















Jim Randell 6:26 am on 24 August 2025 Permalink |
See also: Teaser 2598.
Here is a solution using the [[
SubstitutedExpression]] solver from the enigma.py library.It assumes the dice are “right-handed”, but you get the same answer if you use “left-handed” dice.
The following run-file executes in 93ms. (Internal runtime of the generated code is 498µs).
Run: [ @codepad ]
#! python3 -m enigma -rr SubstitutedExpression # layout (viewed from above): # # I H G # +-------+ # X | A B C | Y # +-------+ # D E F --digits="1-6" --distinct="ADIX,BEH,CFGY" # check the top "is_prime(ABC)" "ABC > max(DEF, GHI)" # the front and back "D + I = 7" "E + H = 7" "F + G = 7" "is_prime(DEF)" "is_prime(GHI)" # total number of exposed spots is also prime "is_prime(sum([A, B, C, D, E, F, G, H, I, X, Y]))" # generate die corners (clockwise around a corner) --code=""" def die_corners(x, y, z, k=7): for (y1, z1) in tuples([y, z, k - y, k - z, y], 2): for t in [(x, y1, z1), (k - x, k - z1, k - y1)]: yield from repeat(rotate, t, 2) """ --code="corners = set(die_corners(3, 2, 1))" # (3, 2, 1) = RH; (1, 2, 3) ]] = LH # check corner configurations "(A, D, X) in corners" "(A, X, I) in corners" "(C, Y, F) in corners" "(C, G, Y) in corners" --answer="ordered(ABC, DEF, GHI)" --template="(A B C) (D E F) (G H I) (X Y)" --solution=""Solution: The 3-digit primes are: 433, 443, 661.
Here is a layout using right-handed dice:
The sum of the spots on the exposed faces is 41.
The die in the middle can be rotated through 180° to give another layout with 433 on the front and 443 on the back, but this doesn’t change the answer to the puzzle.
With left-handed dice the layout is the same, but with the 5 on the left end and the 2 on the right end.
LikeLike
Jim Randell 9:25 am on 24 August 2025 Permalink |
Here is a Python program that finds the same layout(s).
It has an internal runtime of 499µs.
from enigma import (primes, nsplit, tuples, repeat, rotate, find, seq_items, chain, nconcat, printf) # generate die corners (clockwise around a corner) from example (x, y, z) def die_corners(x, y, z, k=7): for (y1, z1) in tuples([y, z, k - y, k - z, y], 2): for t in [(x, y1, z1), (k - x, k - z1, k - y1)]: yield from repeat(rotate, t, 2) # make map (x, y) -> z for (x, y, z) clockwise values round a corner # [use: (3, 2, 1) for RH dice; (1, 2, 3) for LH dice] corner = dict(((x, y), z) for (x, y, z) in die_corners(3, 2, 1)) # look for 3-digit primes that can be formed using the digits 1-6 digits = { 1, 2, 3, 4, 5, 6 } prs = list(ds for ds in map(nsplit, primes.between(111, 666)) if digits.issuperset(ds)) # choose a prime for the front for (i, front) in enumerate(prs): # determine the number on the back back = tuple(7 - x for x in reversed(front)) j = find(prs, back) if j == -1: continue # choose a larger number for the top for (_, top) in seq_items(prs, max(i, j) + 1): # check for valid dice xs = tuple(corner.get((t, f)) for (t, f) in zip(top, front)) if None in xs: continue # left and right exposed faces (x, y) = (xs[0], corner.get((front[-1], top[-1]))) # sum of exposed faces is a prime if not (sum(chain(top, front, back, (x, y))) in primes): continue # output solution ns = sorted(map(nconcat, (top, front, back))) printf("{ns} [top={top} front={front} back={back}; left={x} right={y}]")LikeLike
Frits 9:37 am on 24 August 2025 Permalink |
# I H G # +-------+ # X | A B C | Y # +-------+ # D E F # given two dice faces anti-clockwise at a vertex, find the third # face at this vertex (using a western die if 'same' is True) def third_face(fi, se, same=True): f, s = int(fi), int(se) if s in {f, 7 - f}: raise ValueError oth = [i for i in range(1, 7) if i not in {f, s, 7 - f, 7 - s}] return oth[((f < s) == ((s - f) % 2)) == (same == (s + f > 7))] dgts = "123456" # opposite side dictionary opp = {str(i): str(7 - i) for i in range(1, 7)} # determine valid 3-digit primes prms1 = {3, 5, 7} prms1 |= {x for x in range(11, 52, 2) if all(x % p for p in prms1)} prms = {str(i) for i in range(101, 667, 2) if all(i % p for p in prms1) and all(x in dgts for x in str(i))} # front and back: DEF and IHG fb = [(DEF, GHI[::-1]) for DEF in prms if DEF[0] not in "16" and (GHI := (''.join(opp[x] for x in DEF))[::-1]) in prms] # combine front DEF and back IHG with top ABC ftb = [(f, t, b) for t in prms for f, b in fb if t > f and t > b[::-1] and all(y not in {x, z} for x, y, z in zip(f, t, b))] # determine side faces X and Y and check for prime total of 11 spots ftbxy = [(f, t, b, x, y) for (f, t, b) in ftb if (x := third_face(f[0], t[0])) + (y := third_face(t[2], f[2])) + sum(sum(int(b) for b in a) for a in (f, b, t)) in prms1] sols = set(tuple(sorted([f, t, b[::-1]])) for f, t, b, _, _ in ftbxy) print("answer:", ' or '.join(str(s) for s in sols))LikeLike