Enigmatic Code

Programming Enigma Puzzles

Enigma 810: Wooded acres

From New Scientist #1965, 18th February 1995 [link] [link]

Having a few moments to spare one Thursday, I decided to measure the dining table. This is a fairly conventional piece of furniture in dark oak, rectangular in shape, the longer side less than double the width.

It emerged that whether the surface area is expressed in square yards, square decimetres, square feet, hectares or square light-years, the first significant digit is the same. Furthermore, whether the length of the table is expressed in yards, miles, millimetres or light-hours, the first significant digit is again the same one, and this applies also to the length of the diagonal.

The length of the perimeter is an exact whole number of half-inches, the area in square centimetres is an integral number which is a perfect cube, and the speed of light in my dining room is 0.3 kilometres per microsecond.

Please ascertain the width of the table in feet, to four significant figures.



One response to “Enigma 810: Wooded acres

  1. Jim Randell 6 February 2023 at 11:29 am

    This Python program works in units of tenths of a millimetre, and then considers table with an area up to 100 square feet.

    It runs in 66ms. (Internal runtime is 8.5ms).

    Run: [ @replit ]

    from enigma import (
      powers, inf, sq, quadratic, irange, fdiv, sqrt, intc, intf, hypot,
      seq_all_same, join, sprintf, printf
    r2 = sqrt(2)
    # speed of light (m/s)
    c = 300000000
    # conversions
    conv = dict()
    # lengths (in 10ths of mm)
    conv['mm'] = 10
    conv['dm'] = 1000
    conv['100m'] = 1000000
    conv['in/2'] = 127
    conv['in'] = 254
    conv['ft'] = 12 * conv['in']
    conv['yd'] = 3 * conv['ft']
    conv['mile'] = 1760 * conv['yd']
    conv['lh'] = c * 60 * 60 * 10000
    conv['ly'] = 8766 * conv['lh']
    # areas (in (10ths of mm)^2)
    conv['yd2'] = sq(conv['yd'])
    conv['dm2'] = sq(conv['dm'])
    conv['ft2'] = sq(conv['ft'])
    conv['ha'] = sq(conv['100m'])
    conv['ly2'] = sq(conv['ly'])
    # convert a canonical value <v> to measure <m>
    convert = lambda v, m: fdiv(v, conv[m])
    # measures used
    msA = str.split('yd2 dm2 ft2 ha ly2')
    msl = str.split('yd mile mm lh')
    msd = msl
    # check value <v> gives the same value at 1sf for measures <ms>
    def sf_eq(v, ms):
      return seq_all_same(sprintf("{x:e}")[0] for x in (convert(v, m) for m in ms))
    # consider the area of the table
    # it is an integer number of square centimetres, that is a perfect cube
    for A in powers(1, inf, 3):
      A = A * 10000  # area in (10th of mm)^2
      if convert(A, 'ft2') > 100: break
      # check measures of area
      if not sf_eq(A, msA): continue
      # consider possible perimeters P = n half-inches (with f in [1 .. 2])
      r = convert(sqrt(A), 'in/2')
      for n in irange(intc(4 * r), intf(3 * r2 * r)):
        P = n * conv['in/2']  # perimeter in 10ths of mm
        # calculate f (the ratio of length to width)
        for f in quadratic(4 * A, 8 * A - P * P, 4 * A, domain='F'):
          if 1.0 < f < 2.0:
            w = sqrt(A, f) # width
            l = f * w  # length
            # check measures of length
            if not sf_eq(l, msl): continue
            d = hypot(w, l)
            # check measures of diagonal
            if not sf_eq(d, msd): continue
            # output solution
            printf("A = {A}; P = {P}; f = {f:.2f}; w = {w:.2f}; l = {l:.2f}; d = {d:.2f}")
            fmt = lambda v, ms: join((sprintf("{x:1.3e} {m}") for (x, m) in ((convert(v, m), m) for m in ms)), sep=", ", enc="()")
            printf("-> A: {xs}", xs=fmt(A, msA))
            printf("-> l: {xs}", xs=fmt(l, msl))
            printf("-> d: {xs}", xs=fmt(d, msd))
            # answer is width in feet
            ft = convert(w, 'ft')
            printf("width = {ft:1.3e} ft ({ft:.4f} ft)")

    Solution: The width of the table is: 2.811 feet.

    To the nearest millimetre the table is 857mm × 1613mm (2ft 10in × 5ft 3in), and the diagonal is 1827mm (6ft).

    The ratio of length to width is 1.88.

    The area of the table is 13824 cm², and 13824 = 24³.

    This area can be expressed as:

    1.653e+0 square yards
    1.382e+2 square decimetres
    1.488e+1 square feet
    1.382e−4 hectares
    1.542e−32 square light years

    where the first significant digit in each measure is 1.

    The length of the table can be expressed as:

    1.764e+0 yards
    1.002e−3 miles
    1.613e+3 millimetres
    1.494e−12 light hours

    again, the first significant digit in each measure is 1.

    The diagonal of the table can be expressed as:

    1.998e+0 yards
    1.135e−3 miles
    1.823e+3 millimetres
    1.692e−12 light hours

    and again, the first significant digit in each measure is 1 (although in yards the value is very close to 2).

    It wasn’t clear to me from the puzzle text if the most significant digit had to be the same across all three groups (which as it turns out it is), so my program just requires it to be the same within each group, and there is only one solution.

    And this is the only solution until we reach tables with an area over 1432 sq ft.

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 )

Connecting to %s

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

%d bloggers like this: