Saturday August
13 , 2005
Delphi For Fun Newsletter #40
April 11, 2005: I sent DFF Newsletter #39 last Friday so if you think you are subscribed and did not received one, you are one of the 71 subscribers with an inactive account, full mailbox, unknown user, or whose ISP thinks that DFF sends spam. While watching Tiger win the Master's Golf Tournament yesterday, I wrote a program to help me update the subscribers list. Text File Update is a program that processes a file of bad email addresses against a total subscriber list and deletes the matches (it could be any list of text items). I included a few extra goodies like options to add unmatched transactions, delete duplicate master records , ignore or consider capitalization when matching, ignore leading trailing blanks, etc. For programmers there's version 1 of a TSyncMemo class that allows three lists (Master recs., Update recs., Action taken) to be scrolled synchronously from a single scroll bar.
April 12, 2005: Completed Project Euler! Yesterday I finished the last of the 95 programs in this challenging set of programming projects. 5 of the 18 who have completed all the problems are Delphi programmers. One of them, a non-native English speaker, who also recently made it, expressed the satisfaction best. He wrote "I am happy like a child!". After working five months on the last problem (#60), I can only echo that sentiment and say "Me too!"
April 13, 2005: I corrected a small problem in UBigIntsV2, our large integer arithmetic unit the other day. (Multiplication by a negative 64 bit integers ignored the sign). Rather than update all six DFF programs which use this unit, it was relocated to the DFF Library file. So these programs will now need access to the library in order to recompile successfully: Big Integer test, Multiple Length Long Division, Pell's Equation and Continued Fractions. Big Floating Point Arithmetic, Big Combos , T-Shirt XXL (Armstrong numbers). The error did not affect any of these programs, so no need to re-download executables, but if you have the source code, it would be a good idea to download the Library file to get the latest code.
April 14, 2005: Here is the next version of Cutlist, Version 2.1.3. Cutlist is a woodworker helper program which displays the optimal layout for a set of parts from a given set of material. This version adds the ability to specify a "duplicate count" to simplify entering multiple parts with the same dimension in a project. There's one more pending request - ability to zoom the displayed results across multiple pages for better readability for large projects. Those woodworker guys are really using this! I'll try to get to it next week.
April 15, 2005:
Inverted
Text, Mirror text, Or
Both?
A fellow wrote the other day asking about "mirrored" text for a teleprompter application he was working on. I started out to modify an Inverted Text demo program over in Delphi Techniques, but ended up with an entirely new application. The TestMirroredText program described here uses the Copyrect procedure to copy text from one canvas to another. It turns out that it's smart enough to handle cases where the left and right (or top & bottom, or both sets of) coordinates are reversed. the result is a fairly fast way to flip or mirror, or rotate an image. Along the way, I learned a few more things about re-justifying TMemo lines and setting margins.
April 19, 2005:
Two friends who have an eight-quart jug of water wish to share it evenly. They also have two empty jars, one holding five quarts, the other three. How can they each measure exactly 4 quarts of water?
Here's our version of the classic "Water Jug Problem"
which will let you try your hand at solving this problem, and many
others. If you have trouble finding the 7 required moves, a button click
will show you how!
April 22, 2005: Version 2 of the Mirrored Text Test program was posted today. It adds another piece of the solution for a real teleprompter application: synchronized speed-controlled auto-scrolling of the input and mirrored text. .
April 24, 2005: A big "thank you" to all those who use the Amazon link at the bottom left of our home page to place your orders. Today I received a $16.16 Amazon Gift Certificate for your purchases so far this year. That covers my expenses for a month! On average I seem to get about 2.5% of what you spend, so cumulatively, you have spent a hunk of change! Thanks again.
April 29, 2005: I created a Simple Backtracking Demo on the Beginners page this morning in response to an inquiry from a student. There are already several examples on the website, but I enjoy doing one from scratch because the probability of success is high - it's kind of a test to see if Alzheimer's has kicked yet. So far, so good.
May 4, 2005: Here is my version of Buffon's Needles, is a classic problem which describes a way to estimate Pi by dropping needles on a grid of parallel lines and counting what fraction cross a line.
May 6, 2005:
![]() |
|
Medium difficulty
level: I found 10 , program found 40 more! |
Akerue is a word search game originally posted several years ago. Find as many words as you can from the letter grid and the program will show you those that you missed. Finding more than half is a challenging task. Here's the first update which includes improved word selection and better level of play (limiting the program to smaller dictionaries for easier levels). Why Akerue? Try reading it backwards.
May 10, 2005:
May 22, 2005: Here's a program to Convert Decimals to Fractions requested by a viewer a couple of weeks ago. At the time I gave him a few hints but I assume that the homework assignment is past due by now so I can safely post my solution to the problem. May 25, 2005: A couple of minor bugs fixed today - The UBigIntsV2 Big Integers unit in DFFLibV02 library file had an error in the modulo routine for 64 bit integers. I also made the second operand independent of the first operand in Add operations so that X.Add(X) now works. In our Reaction Times application, the Density Plot program required that Delphi 5 be installed in order for the executable to run. That is no longer the case. May 28, 2005: It didn't take long to for the new Convert Decimals to Fractions program to earn its first update. Regular reviewer/contributor Don Rowlett pointed out that I had once again ignored the fact that Europeans use comma (,) instead of dot (.) as a decimal separator. I told him that's the real reason the USA wants to take over the world. Not for freedom, democracy, or even oil. We really just want everyone else to use our decimal point and date formats! But I did fix the program for now to use Windows "decimal separator" character so it should work where ever. Don also knew of a trick for converting repeating decimals to fractional representation, so the user can now specify whether the input decimal terminates or represents one cycle of a repeating decimal. May 29. 2005: Another viewer, from Sweden this time, pointed out that there was a date format problem in our Astronomy Demo program. Sure enough, in computing Lunar eclipse dates, I tried to get the January 1st date for the current year to internal date format by converting '1/1/2005'. That works fine if your system expects dd/mm/yyyy or even mm/dd/yyyy date formats. Sweden's date format is yyyy-mm-dd which made the StringToDate function complain that 2005 wasn't a valid day of month. It's fixed now so Sweden can start having Lunar eclipses again! June 6, 2005: Some one posed the Four Dice Puzzle to me the other day. The problem is to find a set of 4 special six-sided dice which may have more than 6 dots on a side and may repeat the number of dots on a side. The set, if labeled A B C D, has the property that when rolled in pairs, on average, A beats B, B beats C, C beats D and D beats A! Makes a good non-fair game if you let your opponent choose his die first. You can always select one to beat him. This version lets you set a number of parameters to look for other solution sets and to print the solutions as a deck of playing cards. June 8, 2005: Here are two more simple little programs that I added to the Beginners Techniques page in Delphi Techniques. They do not do much but may illustrate some new techniques for the beginner's repertoire. DrawDice draws a random pair of dice with each button click. CountWords lets you load a text file and get a count and list of the words it contains or a summary of number of occurrences by word. June 9, 2004: One more Beginner's program from a recent Mensa Puzzle-a-Day calendar. I called it Expressions864: Find all solutions where the sum of two numbers equals 864. And by the way, the solution, including the "864" sum must contain all of the digits 1 through 9 exactly once. Only about 35 lines of code to solve this one, including a test to eliminate duplicate solutions. I did also coded the problem in our Brute Force program and uncovered a small bug there. In a feeble attempt to eliminate duplicate solutions, I was eliminating any that had a repeated variable value. But, of course, reusing a single variable value does not mean that the solution is a duplicate. I have simply removed the uniqueness test for now. June 13, 2005: We're packing for a family trip to Germany and Switzerland so DFF will have a hiatus until July. It sounds like Europe has had a cold, wet spring, so we may come back knowing more about Germanic art, culture, and history than originally planned. But, with enough good food and beer, sunny mountaintops will just be a bonus, not a requirement for an enjoyable trip!July 6, 2005: There were 30 DFF feedback emails awaiting my return. Working through those will take a little time. I posted a small correction for the numeric edit components TIntEdit and TFloatEdit today (decimal separator issue for European users). I also made a version of the controls that do not need installation before use that can be downloaded from the same page. July 8, 2005: A small fix for the Intersecting Lines demo was posted today. Overlapping line segments of the same line were not identified as intersecting. Perhaps we should have a new "overlapping" category, but for now we just identify them as "intersecting". July 10, 2005: The Josephus problem : A counting elimination "game" named after the story that Jewish historian/mathematician Josephus Flavius devised a "fair" way to kill off his troops who insisted on suicide rather than surrender to the Roman enemy. 41 of them formed a circle and every third man was eliminated. Maybe not so fair since Josephus, who was not too keen on the idea, selected a position which assured that he would be the last survivor. At that point he decided that perhaps it was best to surrender after all. In fact, the name Flavius is an adoptive name from the Roman family that took him in! July 12, 2005: Long time viewer Don Rowlett has made a hobby of finding (and suggesting fixes for) bugs in DFF programs. Here are two more minor corrections; in Peg Solitaire, the "number of pegs remaining" criteria defining a solution was only checked in Auto-solve mode and was ignored for manual play. It now is checked for both modes. And in Safecracker, the board kept getting smaller as sizes were rounded down from previous size as board sizes were changed. New size calculation is now from original board size. Thanks Don. Keep up the good work!July 14, 2005: I made a couple of corrections to NumEdit2 posted last week, Numedit2 contains versions of our Integer and Float edit controls (TintEdit and TFloatEdit) that do not require installation. Prototype properties "Anchors" and "Text" were not transferred to the new controls when they were created. Now they are.
August 5, 2005: Here's program which solves sets of linear equations using a technique called Gaussian Elimination with Partial Pivoting. Even the title sounds scary. Fortunately, this demo program is usable to those of us who are more results oriented and don't worry about the messy details. As usual, complete source code and other references are available for those who do want to dig in. |
![]() |
|
Oops! |
August 3, 2005: I spent the past two
weeks working on our latest program - a Catapult
Simulator. Users define the mechanical
characteristics of the catapult and the program predicts the flight time,
height, and range of the projectile. Now I guess I had better
head down to the shop and finish that model to see if the program's output has
any relationship to reality.
"On the
road of life, there are drivers and there are passengers...... Be a
driver." - Volkswagen TV ad .
|