Enigmatic Code

Programming Enigma Puzzles

Enigma 1187: Leviticus 19:9-10

From New Scientist #2343, 18th May 2002 [link]

“When you reap the harvest of your land, you shall not reap to the very edges of your field, …, you shall leave them for the poor and the alien: I am the Lord your God.”

The land of Fairfield has put that commandment into its legal code. All the fields of Fairfield are the same size; they are rectangles, 100 metres wide and a whole number of metres long. Each field contains a border strip along each of its four sides. This strip is a whole number of metres wide and is not to be reaped. The width of that strip has been chosen so that exactly half the area of each field is in the strip. I noticed that the digits in the length, in metres, of each field are in decreasing order when read from left to right.

Find the length of each field and the width of each strip.


One response to “Enigma 1187: Leviticus 19:9-10

  1. Jim Randell 28 December 2015 at 8:47 am

    This was a fairly straightforward puzzle to solve, so I amused myself by writing a function to generate overlapping tuples from a sequence. The [[ tuples() ]] function appears in the latest version of the enigma.py library.

    This Python program runs in 33ms.

    # if we consider border around the edge to be of width b/2
    # then the area of the field that isn't border is:
    # (100 - b) * (length - b)
    # and this is half the area of the whole field:
    # (100 - b) * (length - b) = 100 * length / 2
    # rearranging to get length in terms of b:
    # length = b * (100 - b) / (50 - b)
    from enigma import irange, printf
    # generate overlapping n-tuples from a sequence
    def tuples(s, n=2):
      i = iter(s)
      t = list()
        # collect the first tuple
        for _ in irange(1, n):
        while True:
          # return the tuple
          yield tuple(t)
          # move the next value in to the tuple
      except StopIteration:
    # is a positive integer represented in decimal as a sequence of strictly decreasing digits
    def is_decreasing(n):
      return all(a > b for (a, b) in tuples(str(n), 2))
    # consider twice the size of the border
    for b in irange(2, 48, step=2):
      # calculate corresponding length
      (length, r) = divmod(b * (100 - b), 50 - b)
      if r > 0: continue
      # for a solution the digits in length are strictly decreasing
      soln = ('[*** SOLUTION ***]' if is_decreasing(length) else '')
      printf("border={border} length={length} {soln}", border=b // 2)

    Solution: The fields are 621m long, and the border strip is 23m around the edge.

    If we were looking for an increasing sequence of digits then a border strip of 24m and a corresponding field length of 1248m would be the solution.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: