Enigmatic Code

Programming Enigma Puzzles

Enigma 104: Cube balancing odds

From New Scientist #1248, 9th April 1981 [link]

Enigma 104Alf was showing his friend Maisie Moshan a uniform cube, like the one in the sketch, which had sockets at each vertex, mid-edge and mid-face, in each of which a little gold ball could be lodged.

“What I wonder,” he said, “is if I insert two little balls at random, what is the probability that I can then insert a third at a place which will leave the cube properly balanced?”

Maisie pondered. “By ‘properly balanced’ you mean with its centre of gravity still at the centre of the cube?”

“Yes indeed.”

“My guess,” said Maisie, “is that you would improve your chances if, instead of inserting the first at random, you put it at a mid-edge. Then you place the second at random, and the third at your choice, as before.”

Was Maisie right? What is the probability of ending up with a properly balanced cube, with three added balls, under (a) Alf’s system; (b) Maisie’s system?

Enigma 4 was also about balancing a cube.

[enigma104]

Advertisements

2 responses to “Enigma 104: Cube balancing odds

  1. Jim Randell 2 July 2013 at 8:25 am
    from collections import namedtuple
    from itertools import product, combinations
    from enigma import printf
    
    # points
    P = namedtuple('P', 'x y z')
    
    # places where a ball can be placed
    ps = set(P(x, y, z) for (x, y, z) in product((-1, 0, 1), repeat=3))
    ps.remove(P(0, 0, 0))
    
    # first case, two points are chosen at random
    (n1, t1) = (0, 0)
    for (a, b) in combinations(ps, 2):
      # and where would we place a ball for balance?
      c = P(-(a.x + b.x), -(a.y + b.y), -(a.z + b.z))
      balance = (c in ps)
      t1 += 1
      if balance: n1 += 1
    
    # second case: a is an edge
    (n2, t2, a) = (0, 0, P(0, 1, 1))
    for b in ps.difference([a]):
      # and where would we place a ball for balance?
      c = P(-(a.x + b.x), -(a.y + b.y), -(a.z + b.z))
      balance = (c in ps)
      t2 += 1
      if balance: n2 += 1
    
    (p1, p2, m) = (float(n1) / t1, float(n2) / t2, n1 * t2 < n2 * t1)
    printf("(a) {n1} / {t1} (~ {p1:.3f}), (b) {n2} / {t2} (~ {p2:.3f}), maisie correct = {m}")
    

    Solution: (a) The probability of ending up with a balanced cube under Alf’s system is 132 / 325 (≈ 0.406); (b) With Maisie’s system the probability is 10 / 25 (= 0.400). So Maisie was wrong.

  2. Hugh Casement 10 July 2015 at 10:03 am

    These are my thoughts, which probably duplicate Jim’s (but without a program).

    Let us suppose the cube has side length 2 and the centre has coordinates (0, 0, 0).
    There are eight vertices, at (±1, ±1, ±1); twelve edges with midpoints (0, ±1, ±1),
    (±1, 0, ±1), and (±1, ±1, 0); and six faces with midpoints (±1, 0, 0), (0, ±1, 0),
    and (0, 0, ±1). That makes a total of 26 positions for inserting heavy metal.
    There are ½(26×25) = 325 ways of choosing two at random.

    Successful arrangements are
    three edges, e.g. (1, 1, 0), (-1, 0, 1), (0, -1, -1)
    one edge and two faces, e.g. (1, 1, 0), (-1, 0, 0), (0, 0, -1)
    one of each kind, e.g. (1, 1, 0), (0, 0, 1), (-1, -1, -1)
    or any reflexion or rotation of those, where the sum of each of the x, y, and z coordinates is 0. Ignoring rotations or reflexions that are effectively the same,
    we find 132 ways in which a judiciously placed third piece of metal will balance the cube.
    Therefore with Alf’s scheme the probability is 132/325 ≈ 0.40615.

    Whether the cube is genuinely balanced is another matter, but at least when any face is horizontal there is no net moment about the centre. Each such arrangement involves at least one edge position, which may have been Maisie’s reasoning.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: