Home | Introduction | Newsletters | Programs | Feedback
September 28, 2011
Delphi For Fun Newsletter #61
Fall is in the air here in the Southwest Virginia mountains; we might get our first frost this weekend. I have plenty of firewood put up for the winter and can soon stop feeling guilty about not mowing the lawn more often. I decided to publish this quarterly newsletter a few days early since we'll be traveling for the next week or so. First stop is Old Dominion University where our 4th oldest grandchild is a freshman this year. He and his smart and lovely high-school girlfriend are both in the marching band so we plan to attend the ODU football game this weekend and enjoy the band's half-time show. Then we plan to spend a couple of days revisiting Colonial Williamsburg, a complete village where things are made and done as they were 200 years ago. In those days, folks took care of their own needs, not expecting the government to bail them out from every problem. A mind-set that helped make this country great - I wonder how we lost that independent spirit.
The programming front was wide ranging this quarter including a cool animated simulation of multiple pendulums, an investigation of how programs support multiple languages, lots of time adding latitude-longitude scaling to our program which solves (small versions of) the Traveling Salesman Problem, and a few other small projects. Here's the complete list:
July 11, 2011: Here's a real-world simulation program that was fun to write. In simulates a bunch of pendulums of increasing lengths on a rod and viewed from the end of the rod. With careful selection of the lengths, some surprising patterns are formed as they swing. Check out Multiple Simple Pendulums.
July 18, 2011: You have probably used programs asking that you
choose a language at start-up. I suspect that they all use some variation
of the techniques demonstrated in this "Hello World"
program. Translations explores tools and ways to implement foreign language
support in a Delphi program. Give Google the credit or blame for the
quality of the French, German, and Spanish translations included here.
July 25, 2011: There are occasions where it would be convenient to incorporate a text file into the executable module of a program. Doing so eliminates the chance of the text file being accidentally deleted or modified. Today's program StringListToResource, in Delphi Techniques, implements this ability by converting a text file to a "resource" file which may be easily embedded in the executable. Version 2.0 of our Scan Key Codes utility program, which displays name and scan code information as keys are pressed, was also posted today. It is the first test case, eliminating the previously required text file associating keyboard scan codes with key names.
August 16, 2011: Summer is flying by. We've had great time with the family this summer at the expense of programming time. A fair tradeoff IMO. Spare time recently has been spent working on adding Latitude-Longitude Mercator projections to the Traveling Salesman Program with maybe another week to go to wrap it up.
I thank Rob for letting me know that file size reporting for our large file size listing program didn't work for files over 4 GB. List Large Files Version 3.3 posted to day today fixes that problem, so we'll at least have one program posting this month. If you find any other nice easy-to-fix bugs, please let me know J.
August 24, 2011: One of the luxuries of working for free is the ability to ignore self imposed schedules to make time for interesting side trips. One such side trip resulted in today's utility program Make City Location Files. While adding the ability to use latitude-longitude coordinates in our traveling Salesman Problem Solver program, I decided that manually placed dots on a map would not accurately represent coordinates so I needed to go the other way (from lat-long to pixels). This meant finding a source to assign coordinates to cities. Since cities often cover many square miles, assigning a single point is necessarily a rough indicator, but how to get even that? I did not succeed in finding a ready-made solution but did find an official US government zip code file which assigns lat-long coordinates to zip codes. Many zip codes may reference the same citiy but we should be able to average these coordinates by city to get reasonable location values for each of the 50,000 or so zip code location reference names. Interesting stuff!
August 28, 2011: Another side trip thanks to a viewer inquiry about alternate ways to randomly cut a stick into three pieces to form a triangle. The original version computed the probability of forming a triangle if a stick is broken into 3 pieces by making two independent random cuts.. This is the first update to a program posted 7 years ago; Random Triangles Version 2 explores three other ways when the second cut location is influenced by the first.
September 1, 2011: Last Tuesday's puzzle from our
Mensa Puzzle-A-Day calendar had me stumped until I remembered that I had written
a program to find words meeting given conditions within a grid of letters.
With the list of possible solution words, finding those that satisfied the clues
was easy. When I decided to save the puzzle for future reference, I
realized that the Save and Load buttons failed to include the clues!
Alphabet Grid Version 3.0
posted today adds the puzzle to the download files and fixes that
problem of the missing clues.
September 7, 2011: I've been working off-and-on for several weeks
at adding Latitude/Longitude coordinate handling to our Traveling Salesman
Problem solver. TSP Version 3.0
was a fun exercise and satisfying to be able to place any number of US
cities on a Mercator projection map based on Lat/Long coordinates once the user
locates two cities on the map. There's lots more that could be done,
but it's a start.
September 9, 2011: A new puzzle and a small fix to an old friend, Brute Force, today. The fix involved incorrect sorting of solution rows when multiple solutions existed. Here is the puzzle which uncovered the problem and which I've added to the download files. Brute Force solves puzzles like this one by evaluating all possible arrangement of allowed variable values. In this case, there are 386,000 ways to assign values 1 through 9 to variables "a" through "i". Variables were assigned right to left and top to bottom in the grid, so we have equations like a=3, b=6, c<>5, c<>7, c<>9, etc. where "<>" means "not equal to". In all, it took 26 equations to get down to a single solution, but only 1/10th of a second for my laptop to find it!
September 18, 2011: One of the first programs
posted on DFF over 10 years ago, was a beginner's level program showing how to
draw an analog clock. A later version answered the question "In a 12 hour
period, how many times are the hour and minute hands of an analog clock at right
angles to each other?" Judy, an enthusiastic math teacher in Australia,
recently wrote and asked if I could stop the animated clock at the right angles
to help the kids understand what is going on as the clock hands turn. Of
course I can; I love to help teachers!. Here's
Clock Angles Version 2 posted today.
September 24, 2011: Subtracting Squares is a two player game defined this way:
"A positive integer is written down and two players take turns subtracting squared integer values (1,4,9, etc.) until one player leaves zero, in which case he (or she) is the winner. What square should the first player subtract if the original number is 29?"
I adapted the game from Mathematical Bafflers, Angela Dunn, Dover Publications and, in my version, the starting value can range from 1 to 50 and computer can be one of the players.
To subscribe or unsubscribe from this newsletter, visit http://delphiforfun.org/newsletter.htm
359,000 visitors and 271,500 program downloads in the past 12 months!