Sunday Times Teaser 2951 – Imprismed
by Stephen Hogg
Published April 14 2019 (link)
A right regular prism has two ends with identical faces, joined by oblong rectangular faces. I have eight of them, with regular convex polygonal end-faces of 3, 4, 5, 6, 7, 8, 9 and 10 sides (triangle, square and so on). They sit on my flat desk (on oblong faces), and each prism has the same height.
I chose three prisms at random, and was able to slide them into contact, broadside, in such a way that the middle one overhung both others (and could be lifted without disturbing them). Also, I was able to slide one outer prism to the other side, and the new “middle” prism was overhung by both others (and so vertically “imprisoned” by them).
I was able to do all this again with three randomly chosen remaining prisms.
Give the prior chance of this double selection (as a fraction in lowest terms)
-
Brian Gladman permalink123456789101112131415161718192021222324252627282930313233343536373839from itertools import combinations, permutationsfrom fractions import Fraction as RF# the number of sides on the polygonspolys = range(3, 11)# map polygons to the set of polygons that they trapis_under = { 5: {3, 6, 7, 9, 10},6: {3, 7},7: {3},9: {3, 6, 7, 10},10:{3, 7} }# check if a triple of polygons is of the special formdef is_special(x):for l, m, r in permutations(x):# the middle polygon must trap both the other twoif {l, r} <= is_under.get(m, set()):# after the re-arrangement the original right polygon# must trap the original left one or vice versaif l in is_under.get(r, set()) or r in is_under.get(l, set()):return Truereturn Falsec_total, c_special = 0, 0# consider all possibilities for the first three polygonsfor a in combinations(polys, 3):# record if this triple has the special forma_is_sp = is_special(a)# consider all possibilities for the second three polygonsfor b in combinations(set(polys).difference(a), 3):# count all pairs of triplesc_total += 1# count all pairs of triples that are both of the special formc_special += a_is_sp and is_special(b)print(f"Probability = {c_special}/{c_total} = {RF(c_special, c_total)}")