Enigmatic Code

Programming Enigma Puzzles

Enigma 200: Neat paddocks

From New Scientist #1346, 24th February 1983 [link]

I gave four of our local Young Farmers the same number of standard hurdles and asked each of them to make a neat paddock which would require all his hurdles to fence it completely. All succeeded. All the paddocks turned out to have quite different dimensions. Edgar’s and Fred’s had the same area. Mervyn’s and Peter’s had the same area.

What was the smallest number of hurdles I could have given to each?

Enigma 200

A neat paddock is a 6-sided paddock composed of 2 contiguous squares, like the one in the diagram, with each side fenced with an exact number of standard hurdles.



One response to “Enigma 200: Neat paddocks

  1. Jim Randell 19 June 2014 at 9:27 am

    This Python program runs in 37ms.

    from itertools import count
    from collections import defaultdict
    from enigma import printf
    # for a neat paddock made out of squares of side a and b (a > b)
    # we need 4a + 2b hurdles
    # so for a=2, b=1 we need 10 hurdles
    # consider increasing numbers of hurdles in the perimeter
    for n in count(10, step=2):
      # accumulate (a, b) pairs by area
      d = defaultdict(list)
      for b in count(1):
        (a, r) = divmod(n - 2 * b, 4)
        if not(b < a): break
        if r > 0: continue
        d[a ** 2 + b ** 2].append((a, b))
      # count areas with multiple pairs, and find 4 values
      if sum(len(ps) for ps in d.values() if len(ps) > 1) > 3:
        printf("n={n} {d}", d=dict(d))

    Solution: The smallest possible number of hurdles given to each farmer is 70.

    One pair of farmers would each enclose an area of 250 sq hurdles (13 square + 9 square and 15 square + 5 square), the other pair would each enclose an area of 265 sq hurdles (12 square + 11 square and 16 square + 3 square).

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: