Enigmatic Code

Programming Enigma Puzzles

Enigma 34: Cornered

From New Scientist #1176, 11th October 1979 [link]

“The figure”, said Professor Mortis, “shows a straight rod XY of quite infinite rigidity and totally infinitesimal width which is too long to be pushed around the right-angled corner in the corridor. It came along arm A, and it has got stuck on its way round into arm B. Now if you measure the width of the arms in the figure and interpret them according to the scale so helpfully provided, you will know the exact width of each arm, won’t you? Both figures are an exact number of inches, right? Yes. And now you can tell me, can’t you, the length of the longest rod which will just go round the corner? It must of course be straight and rigid and widthless, and incidentally it is still so heavy that it has to be pushed along flat on the floor.”

“Ten foot five,” I said.

“Perfectly right,” said he.

You can’t measure the figure as I did, because the figure shown here is only a rough copy of the professor’s; but can you tell me the width in inches of the arms A and B?

[enigma34]

Advertisements

2 responses to “Enigma 34: Cornered

  1. Jim Randell 7 January 2013 at 9:54 am

    A bit of trigonometry and calculus, yields a surprisingly simple formula for the shortest permissible rod given the widths of the arms.

    You can use Python floats to get a good approximate answer in 45ms, but here I’ve used SymPy to get an exact answer. It is somewhat slower though – it runs in 850ms.

    # a line emanating from the internal corner at an angle theta along Arm A
    # (of width a) will hit the wall at a distance of: z1 = a / sin(theta)
    #
    # likewise the line extending in the opposite direction along Arm B (with
    # width b) will hit the wall at a distance of: z2 = b / cos(theta)
    #
    # so the overall length of the line is: z = z1 + z2
    #
    # as theta changes the line length changes -
    # it is infinite when theta = 0 (the line continues along Arm A indefinitely),
    # and also when theta = 90 degrees (along Arm B), but inbetween it achieves
    # some minimum length, which is the length of the longest rod that can pass
    # the corner
    #
    # the derivative of the length with respect to the angle is:
    # z' = -a cos(theta) / sin^2(theta)  +  b sin(theta) / cos^2(theta)
    #
    # so, z achieves a minimum when z' = 0, i.e. when:
    # a cos^3(theta) = b sin^3(theta)
    # a / b = sin^3(theta) / cos^3(theta)
    #       = tan^3(theta) as tan(theta) = sin(theta) / cos(theta)
    #
    # so the minimum length z occurs when:
    # tan(theta) = a^(1/3) / b^(1/3)
    #
    # and by considering a right-angled triangle containing theta we can see:
    # sin(theta) = a^(1/3) / h, cos(theta) = b^(1/3) / h
    # where: h^2 = a^(2/3) + b^(2/3)
    #
    # substituting these into the formula for z we get the length of the rod is:
    # z = a h / a^(1/3) + b h / b^(1/3)
    #   = a^(2/3) h + b^(2/3) h
    #   = (a^(2/3) + b^(2/3)) h
    #   = (a^(2/3) + b^(2/3)) (a^(2/3) + b^(2/3))^(1/2)
    #   = (a^(2/3) + b^(2/3))^(3/2)
    #
    # we are told that the maximum length of rod is 125 inches, so:
    # 125 = (a^(2/3) + b^(2/3))^(3/2)
    # 125^(2/3) = a^(2/3) + b^(2/3)
    # i.e. a^(2/3) + b^(2/3) = 25
    
    from sympy import Rational
    from enigma import irange, printf
    
    p = Rational(2, 3) # or (if using floats): 2.0 / 3.0
    
    # assume a < b for uniqueness (like in the diagram)
    for b in irange(1, 125):
      for a in irange(1, b):
        z = (a ** p + b ** p)
        if z == 25: # or (if using floats): abs(z - 25.0) < 1e-9
          printf("a={a} b={b} z={z}")
    

    Solution: Arm A is 27″. Arm B is 64″.

  2. Brian Gladman 8 January 2013 at 10:27 pm

    This is a really nice enigma with the answer that [z^(1/3)]^2 = [(a^(1/3)]^2 + [(b^(1/3)]^2 so if we have any Pythagorean triple (p, q, r), then a = p^3, b = q^3 and z = r^3 will provide a solution, The triple in our case is the most well known one: (3, 4, 5).

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: