Enigmatic Code

Programming Enigma Puzzles

Enigma 1402: Folded rectangle

From New Scientist #2562, 29th July 2006

I take a rectangular piece of paper whose sides are each a two-figure number of centimetres, and fold it so that one corner touches the opposite side (as shown below).

Enigma 1402

The areas of the two triangles A and B are each a two-figure number of square centimetres.

How big was my piece of paper?



2 responses to “Enigma 1402: Folded rectangle

  1. Jim Randell 15 August 2013 at 9:12 am

    This Python program finds the solution based on the observation that the triangles A and B are (mathematically) similar. It runs in 58ms.

    # let a, b be the sides of the original rectangle, a > b
    # and the fold divides a into a1, a2 and b into b1, b2
    # such that A has sides a1, b1, b2
    # and B has sides b, a2, a.
    # A and B are similar so: b/a1 = a2/b1 = a/b2
    # consider the area B and side b (both 2-digit integers)
    # B = (a2 b) / 2, so: a2 = 2B / b
    # also: a2^2 = a^2 - b^2, so a2^2 is an integer
    # so let a2^2 = m = 4B^2 / b^2
    from fractions import Fraction as F
    from enigma import irange, is_square, printf
    for B in irange(10, 99):
      for b in irange(10, 99):
        # b^2 must divide 4B^2
        (m, r) = divmod(4 * B * B, b * b)
        if r > 0: continue
        # a^2 = b^2 + m, and a is a 2-digit integer
        a = is_square(b * b + m)
        if a is None or not(9 < a < 100): continue
        # a2 = 2B / b
        a2 = F(2 * B, b)
        a1 = a - a2
        # from similar triangles: b/a1 = a2/b1
        b1 = F(a1 * a2, b)
        # and area A = (a1 b1) / 2
        A = F(a1 * b1, 2)
        # but it needs to be a 2-digit integer
        if A.denominator > 1 or not(9 < A < 100): continue
        printf("a={a} [{a1}+{a2}] b={b} [{b1}+{b2}] A={A} B={B}", b2=b - b1)

    Solution: The piece of paper was 20cm × 16cm.

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: