Search

 Search WWW Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

Support DFF - Shop

If you shop at Amazon anyway,  consider using this link.

We receive a few cents from each purchase.  Thanks

Support DFF - Donate

If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa® Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

(Hint: If you can wait, current year calendars are usually on sale in January.)

Contact

 Search DelphiForFun.org only

Problem Description

Cut a square into four pieces that can be reassembled into an equilateral triangle with the same area.

Background & Techniques

A geometric dissection is a division of a polygon into pieces that can be rearranged to form a polygon of a different shape.    The self taught mathematician and British puzzleist, H. E. Dudeney, published this interesting geometric dissection in 1902.

This program allows you to print a square and triangle of appropriate size so you can work on it yourself, or print the set of polygons that you can rearrange into either shape.

There is also a button to bring up a form with some of the construction details, for those that may be interested.

As a programming exercise, there were two challenges.  First was to determine where to draw the lines which form the polygons.   The construction usually proceeds from the triangular form - the problem then being to translate these corner points appropriately to the square.  I added a PointPerpendicularLine function to define the last two polygon lines.  Also a Dist function to locate the offsets for polygon corners when redrawing them  on the square

The second challenge was transferring the image to the printer.   Simply "stretchdrawing" the image canvas to the printer canvas works, but the printout appears rather coarse.  (Since  typical screen resolution is around 100 pixels per inch and a typical printer prints at 600 pixels per inch, the printed pixels will be about 6 times larger than on the screen image.)  It's much better to redraw the image on the printer canvas.  The "trick" used here is to generalize the drawing routines so that the same code is used for the onscreen displays and for the printer canvas.

Suggestions for Further Explorations

I had planned to animate the solution - the polygons can be "hinged"  so that with three shared corners as hinge points a you can rearrange them into either shape.  You can  find several Java versions on the web, so it can't be that hard  to do  in Delphi.   Just too many other things to do right now - we'll get back to it one of these days.

Apparently there are many other dissections, octagon to square, pentagon to square, etc.

 Original Date: October 16,  2002 Modified: July 29, 2017