Enigmatic Code

Programming Enigma Puzzles

Enigma 1495: An unfolding story

From New Scientist #2657, 24th May 2008

I took an A3 sheet of paper and cut from it a rectangle with each of its sides a whole number of centimetres long. I discarded the rest of the sheet. Then I folded the rectangle so that one corner coincided with the diagonally opposite corner. That left me with a pentagon in which each of the sides was a whole number of centimetres long.

How long were the sides of the rectangle?

Note: An A3 sheet of paper has dimensions of 297 mm × 420 mm.

[enigma1495]

Advertisements

One response to “Enigma 1495: An unfolding story

  1. Jim Randell 4 November 2012 at 11:23 pm

    The following Python program runs in 41ms.

    from enigma import irange, is_square, printf
    
    # A3 paper is 42.0 cm x 29.7 cm
    
    # a < b
    for a in irange(1, 29):
      for b in irange(a + 1, 42):
    
        # the shortest side c makes a right-angled triangle with
        # adjacent side a and hypotenuse b - c
        (c, r) = divmod(b ** 2 - a ** 2, 2 * b)
        if r > 0: continue
    
        # and the longest side d makes a right-angled triangle with
        # adjacent sides a and b - 2c
        d = is_square(a ** 2 + (b - 2 * c) ** 2)
        if d is None: continue
    
        printf("a={a} b={b} c={c} d={d}")
    

    Solution: The rectangle was 24cm × 32cm.

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: