Enigmatic Code

Programming Enigma Puzzles

Enigma 1221: Flower beds

From New Scientist #2377, 11th January 2003 [link]

Some time ago (Enigma 1112) George constructed a patio divided into seven rectangular zones of different shapes. He is now planning to divide his large square garden into seven rectangular flower beds. The beds are all different shapes, but all have the same area and cover the whole area of the garden with no gaps.

The width of the rose bed is exactly 25 feet. The side of the square garden is also a whole number of feet.

How many feet?

[enigma1221]

Advertisements

One response to “Enigma 1221: Flower beds

  1. Jim Randell 2 July 2015 at 8:20 am

    First we need to find a way dividing a square into seven non-congruent rectangles of equal area.

    After some experimentation I ended up looking at a diagram like this:

    Enigma 1221 - Diagram

    (In fact, I think 7 is the smallest (non-trivial) number of non-congruent rectangles of equal area that a square can be divided into).

    If we consider the square to have sides of length 1, then we want to see if we can make the rectangles be non-congruent and have area 1/7.

    If we know one dimension of a rectangle, then the other can be deduced.

    So suppose rectangle A has width x, then its height must be 1/(7x).

    Given the dimensions of A we can work out the width of B, and the height of F. And from these the height of B and width of F follow.

    So we can chase the dimensions of the rectangles around: A → B → C → D, and A → F → E → G.

    Then we observe that height(G) = height(C) + height(D), this gives us an equation to solve for x.

    Once we have candidate values for x we can check that the rectangles are non-congruent (i.e. no two rectangles share a dimension).

    We are told that one of the rectangles has one dimension that is 25 feet and the whole garden has dimensions that are a whole number of feet. So we can look at the multiplier required to multiply each dimension up to 25, and if that multiplier is a whole number then that gives us the dimension of a possible square garden.

    Here I’ve used SymPy to do the hard work. This Python program runs in 4.26s.

    from sympy import symbols, Eq, solve
    from itertools import combinations
    from enigma import printf
    
    x = symbols('x')
    
    # determine width from height (or height from width)
    def fn(d):
      return 1 / (7 * d)
    
    # triangle A has width(A) = x
    wA = x
    hA = fn(wA)
    
    # triangle B has width(B) = 1 - width(A)
    wB = 1 - wA
    hB = fn(wB)
    
    # triangle C has height(C) = height(B) - height(A)
    hC = hB - hA
    wC = fn(hC)
    
    # triangle D has width(D) = width(B) + width(C)
    wD = wB + wC
    hD = fn(wD)
    
    # triangle F has height(F) = 1 - height(A)
    hF = 1 - hA
    wF = fn(hF)
    
    # triangle E has width(E) = 1 - width(F)
    wE = 1 - wF
    hE = fn(wE)
    
    # triangle G has height = 1 - height(A) - height(E)
    hG = 1 - hA - hE
    wG = fn(hG)
    
    printf("A=[{wA}] x [{hA}]")
    printf("B=[{wB}] x [{hB}]")
    printf("C=[{wC}] x [{hC}]")
    printf("D=[{wD}] x [{hD}]")
    printf("E=[{wE}] x [{hE}]")
    printf("F=[{wF}] x [{hF}]")
    printf("G=[{wG}] x [{hG}]")
    printf()
    
    def rectangle(x, v, *args):
      return tuple(a.subs(x, v).simplify() for a in args)
    
    def is_distinct(*rects):
      for (P, Q) in combinations(rects, 2):
        p = P[0]
        for q in Q:
          if (p - q).simplify() == 0: return False
      return True
    
    # solve height(G) = height(C) + height(D) for x
    for v in solve(Eq(hG, hC + hD)):
      # determine the actual dimensions of the rectangles
      A = rectangle(x, v, wA, hA)
      B = rectangle(x, v, wB, hB)
      C = rectangle(x, v, wC, hC)
      D = rectangle(x, v, wD, hD)
      E = rectangle(x, v, wE, hE)
      F = rectangle(x, v, wF, hF)
      G = rectangle(x, v, wG, hG)
    
      # no two rectangles can share a dimension
      if not is_distinct(A, B, C, D, E, F, G): continue
    
      # and some dimension is 25
      for d in A + B + C + D + E + F + G:
        f = 25 / d
        if f.is_integer:
    
          printf("x={v}")
          printf("A={A}")
          printf("B={B}")
          printf("C={C}")
          printf("D={D}")
          printf("E={E}")
          printf("F={F}")
          printf("G={G}")
          printf("f={f} [{d} -> 25]")
          printf()
    

    Solution: The square garden is 105 feet square.

    For the unit square the dimensions of the rectangles are:

    A: (1/15)(7 + √19) × (1/14)(7 – √19) ≈ 0.757 × 0.189.
    B: (1/15)(8 – √19) × (1/21)(8 + √19) ≈ 0.243 × 0.589.
    C: (1/15)(1 + √19) × (5/42)(√19 – 1) ≈ 0.357 × 0.400.
    D: (3/5) × (5/21) ≈ 0.6 × 0.238.
    E: (1/15)(8 + √19) × (1/21)(8 – √19) ≈ 0.824 × 0.173.
    F: (1/15)(7 – √19) × (1/14)(7 + √19) ≈ 0.176 × 0.811.
    G: (1/15)(√19 – 1) × (5/42)(1 + √19) ≈ 0.224 × 0.638.

    (Note how the irrational rectangles form pairs where the signs in the expressions are changed: A & F, B & E, C & G).

    When everything is scaled up to a 105 × 105 square, the rational rectangle D has dimensions 63 × 25.

    I you do the maths you end up with the following equation:

    105x³ – 128x² + 42x – 4 = 0

    which factors as:

    (7x – 2)(15x² – 14x + 2) = 0

    Which gives rise to the solutions:

    x = 2/7
    x = (1/15)(7 ± √19)

    In the first case the rectangles are not non-congruent.

    The second case gives rise to the solution given above, and its reflection.

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: