October 2, 2013
Delphi For Fun Newsletter #69
Fall is in the air, after a summer with extreme rainfall in August instead of extreme heat. The firewood supply for this winter is mostly mostly complete and the site for the new garage is ready for the delivery of the pre-fab in a couple of weeks. We purchased a Ford C-Max in June, deciding to become a two vehicle family, keeping our AWD (All Wheel Drive) Mountaineer for the snow and ice to come. It will reside snugly in its own new garage between outings. The C-Max is getting 44 MPG so far; not bad for having to descend (and climb) 2500 feet to nearest grocery store. That's enough to make it vehicle of choice, weather and required capacity permitting.
Significant projects planned for this quarter include:
Below are links to the the 3rd quarter projects.
July 9, 2013: Key Scan Codes Version 3.1 posted today today fixes a problem introduced in V3.0 in the "Last Key Pressed" display. When there is no symbol associated with a key, the key name is displayed and long key names could overlay the "Caps Lock" and Num Lock" status displays. Also this version shows the symbol rather than the key name for punctuation and other special keys which have an associated symbol.
July 10, 2013:
Our Sudoku program is a helper,
solver, and generator for that popular puzzle type. Like most of my
programs, I wrote this one because it seemed more fun and less tedious
than solving Sudoku puzzles by hand. There are dozens of
similar programs around, but none in Delphi that I was aware of at the time.
In any event, I had fun writing it and was quite satisfied with the "helper"
functions which allow users to enter and solve puzzles, and see "hints" about which number might fill empty
cells. The program could also generate random puzzles with a specified
number of "given" or empty cells. The generation task is the toughest nut
to crack as the number of given cells gets smaller and the number of possible
solutions to check for uniqueness increases.
4.0 posted today implements a new search algorithm which reduces the feasible
lower limit from 28 to 23 pre-filled cells. The absolute lower limit for a
puzzle with a unique solution has been proven (not by me!) to be 17 givens,
so our work is not yet finished but we are one step closer today.
July 17, 2013:
spent a few more days working on
Sudoku Generator V4.1, posted today, which finds puzzles
with 21 filled cells (down from23) after several minutes of searching. Two
puzzles with 20 filled cells were generated but the longer solve time for the
one shown here was an impractical 4 hours. Reason enough to put it to rest
July 24, 2013: 375 years ago Pierre Fermat conjectured that no two integers raised to power N could sum to an integer raised to that power for N > 2 (Fermat's Last Theorem), e.g. no sum of two cubed integers can ever sum to a cubed integer. It took 350 years for someone to prove the conjecture really was a theorem applying to all positive integers. It is called "Last" because it was the last of his asserted theorems to remain unproven for many years (until 1995). In 1769, Leonhard Euler, while not having proven Fermat's Last Theorem, had found a sum of 3 cubes which was the cube of an integer and published a generalized conjecture that at least k integers were required if the sum of their kth powers was itself to be the kth power of an integer. This is Euler's Sum of Powers Conjecture. It took almost 200 years before the first counterexample was found in 1966. I decided to try to to find it myself and Euler's Sum of Powers program, posted today in our Math section, does find the 5th power counterexample in about 8 seconds using a direct search technique. A 4th power counterexample was found in 1988, but the numbers are too large to be found by my program in its current form. To date, no counter example has been found for powers greater than 5 so I don't have much hope that this will be the tool to do it. But it will find all the Pythagorean triples (a2 + b2 = c2) that one could ever want! Oh, and the program makes it easy to recognize Plato's number; the smallest (only?) sum of cubes of 3 consecutive integers equal to the cube of the next (4th) consecutive integer. Fun!
July 28, 2013:
Our "Brain Games" daily calendar puzzles
are usually pretty good, but the author of this one thinks that "Cyclist" is the
only answer. Writing a program seemed more fun than simply turning
the calendar page over find the solution. A 50 line beginner's level program
performing a search of our 62,000 word dictionary finds the solution quickly -
all 211 of them! Boy, did the Brain Game guy get this one wrong!
Check out Word Search,
the latest addition at the bottom of the Beginner's page.
August 13, 2013: The Challenging Math Teasers program posted today implements three problems of the 100 presented in the "Challenging Mathematical Teasers" book by J.A.H. Hunter and published by Dover Publications. The puzzles generally require math techniques beyond simply solving an algebraic equation or two. The three presented here were chosen randomly are easily amenable to programmed solutions (and have relatively short descriptions :>). By the way, the above book link to Amazon offers a number of good used copies for $0.01 + $3.99 shipping, if you reside in the U.S. and act quickly.
The program is a one day effort while taking a break from the "Find All Polygons" program I have been wrestling with for the past two weeks. Who knew polygons could be so hard to find?
I placed this program in the Math Topics section of DFF but also indexed it under Delphi Techniques and Beginners categories since it does illustrate some useful number manipulation techniques with less than 20 source code statements to handle each of the 3 problem buttons.
August 22, 2013:
After a month of on-and-off effort, here is
Find All Polygons, a program to
look for polygons, closed figures formed from connected straight
line segments. According to Wikipedia, "Polygon" is derived from Greek
with literal meaning "many corners". Typically, but not always,
the number of corners, (vertices), equals the number sides (edges). I
learned much about them in the course of writing this program including the
many ways that arbitrary closed sets of of lines may not be
valid polygons. The program analyzes several different sample figures
including one from which several hundred polygons can be selected.
Needless to say, I have not examined all of them so there still may be
polygons missed or non-polygons selected. Let me know if you find
August 26, 2013:
Find All Polygons, Version 3.2
posted today is better than last week's posting at finding all polygons at
a given search level. When I added the figure from our "How Many
Triangles?" program to this program, I realized that some of the interior
nodes (created when interior lines intersect) were not being examined during the
polygon search. The problem is corrected today. The easily checked
polygon counts (the Tennis problem's rectangle counts, the Triangles
problem's triangle counts, and the the primitive counts for any figure are now
correct. (Total rectangle and triangle counts are found by limiting "Max
Search Depth" values to 5 and 4 respectively.)
September 8, 2013: George has provided another opportunity for me to teach (and learn) Delphi programming techniques this week. His problem was how to sort several hundred file names with embedded numbers so that numeric values were honored. The default lexicographic sort arranges these sample files names as ( A1.gif, A10.gif, A1A.gif) because comparisons are made left to right and in the 3rd position "." comes before "0" comes before "A". Delphi's TStringList component however has a CustomSort feature which allows us to sort in the desired sequence as (A1.gif, A1A.gif, A10.gif). Program CustomStringListSort illustrates how it can be dome.
September 21, 2013:
My British friend, George, has provided material for
all three projects this
month. Here is a
"Delphi Techniques" program,
Blend Drawing Demo, which explores
his latest problem: semi-transparent shading of a selected quadrant of a
TImage bitmap. Extensions added features to control blend color,
intensity, location, and speed "just for fun".
This is my 75th year and reminders of that are occurring more frequently each year. Below are few relevant quotations about aging but the one most pertinent to me doesn't even mention age. It's the "Irish Prayer" which says "Change what you can change, accept what you can't change, and be smart enough to know the difference". I believe I am.
To subscribe or unsubscribe from this newsletter, visit http://delphiforfun.org/newsletter.htm
357,300 site visits and 284,770 program downloads in the past 12 months!