Friday,
February 28, 2003
Delphi For Fun Newsletter #31
Everyone I talk to, at least here in the Eastern U.S., is ready for spring. But in between shoveling snow, chopping ice, and hauling wood, the nasty days of winter do provide a good excuse for some nice long programming sessions. Several of the postings in the past couple of months have been enhanced versions of existing programs, and most of those resulted from user feedback. Thanks again to all of those viewers that took the time to write when they found a bug or had a suggestion for an enhancement. And there are a number of new items that I found interesting enough to implement. As usual the number of projects that I want to work on continues to grow faster than I can get them written. Hooray!
I helped out at then regional "MathCounts" competition last week. It seem to be a great program to get 6th, 7th, and 8th graders interested in the "Joy of Math". Visit their website at http://mathcounts.org for more information. And if you climb "Math Mountain" there, please let me know how to determine the ten's digit of the expansion of 171933. (I think those were the values, it was the second question in one of the levels, but I can't locate it now. The base was 17, so if you can find the ten's digit for one large power, you could probably find it for any.)
Here's "What's New" since last time.
December 17, 2002: The sum of the cards in the crossbar and in the upright in this T-shaped arrangement is the same. Can you find 17 more arrangements where this is true? (Rearranging cards within the crossbar or upright doesn't count, neither does exchanging the roles of the crossbar and the upright).
This "T" Card Sum
program will help keep track as you search, and show you the ones you
missed. Another puzzle adapted from one invented by British puzzle
maker H. E. Dudeney.
December
20, 2002: Today we have an updated version of the
Knight's Tour program. The problem is to place a Knight chess
piece on a standard chessboard and move it 63 more times landing exactly
once on every square. I have a new Norwegian friend, a retired
science teacher, who writes good Delphi code for a hobby.
(Meaning he thinks and writes a lot like I do. <g>) He
pointed out a few omissions in the original version including
ability to specify a start location for the tour and the ability to
generate closed tours. The final move of a closed tour is positioned
so that the next move could start a repeat of the same
tour. Both features have been added to this version.
January 5, 2003: I hope Santa was as good to everyone as he was to me. A new Case Folding Hunter (hunting knife), a binary clock, a box of dark chocolate covered cherries, and several new puzzle and recreational math books. Who could ask for anything more?
Here's is the first program on DFF not written by me. Molecules is program which simulates molecular motion in several interesting ways. Retired Science teacher Arne is a talented amateur Delphi programmer and correctly guessed that this program would appeal to me. I made a few minor changes but the majority of the code is as he wrote it. I enjoyed it, hope you will too.
(Let me add that this is not an invitation to submit your favorite code. Publishing other's code is not the most fun part of this job - but in this case I found the project interesting, the code was written in my style, and Arne offered to buy me a beer if I ever come to visit his hometown. One such offer every couple of years may be the limit.)
January 10, 2003: I ran across an interesting site this week at mathschallenge.net. I'm not sure who sponsors it, but it seems to be a educational site with lots of math and programming problems. (Probably British since "math" comes out "maths".) I enrolled in their "Project Euler"; a set of graded programming projects, at least 8 levels with 3 problems per level. You must enter the correct numeric answer for two of the three problems in a level to gain access to the next level. I've completed the first 17 so far and the highest score is 21, so old "delphiforfun" may be at the top of the list in another week. Today it took about 6 hours to solve #17: "How many letters are in the written words for the numbers 1 to 1000?" That time includes about 4 hours of debugging to discover that I didn't know how to spell the word for 18. How many "t"s do you think it has?
I'm posting this in case there are Delphi programmers out there who may want to take on the challenge. I plan to publish some of my solutions here (maybe odd or even numbered programs) and will certainly entertain feedback questions about those that I have completed. If you do sign up, consider making "delphi" part of your handle - maybe we can help subtly spread the word about what a great language it is!
January 12, 2003: Here is a marble
game I ran across in one of those Christmas gift puzzle books, "1000
Playthinks", Ivan Moscovich, Workman Publishing.
The objective of Rally is to put
the blue marbles where in red marbles are now by rotating marbles in their
horizontal and/or vertical tracks.. Might provide a few
minutes entertainment solving it, maybe more if you want to find the
minimal 3 move solution. And even more if you want to write the code
to dynamically generate that track and animate the marbles!
January 18, 2003: Big Combos is a program that will
display very large combinations and permutations. If you've ever
wondered about the millionth (or billionth, or trillionth)
permutation of the letters of the alphabet, this program is just for
you. If you find a good application for this information, let
me know.
January 20, 2003: Albrecht Durer (actually Dürer) created the Durer Magic Square as one element of a copperplate engraving in 1514. (Notice the date in the bottom row.) I used it as the base to enumerate all 86 solutions in this program which also lets you try to find solutions yourself. It's surprisingly hard - I have never managed to find even half. By the way, astute viewers will note that the same 86 solutions exist for any 4X4 magic square containing the numbers 1 through 16. Now whether this one has the most symmetric solutions is an interesting question that someone may have answered - but not this programmer.
January 22, 2003: 10 Easy Pieces is a set of the first ten even numbered programs from the Euler Project programming challenge at educational site mathschallenge.net. If you want to take the challenge, I suggest you go there, sign up, and work on the problems first. If you just want to see how 20 or 30 lines of Delphi code can solve problems like
the sum of all prime numbers up to 1,000,000.
the sum of the digits in the expansion of 100 factorial.
the largest palindrome that can be formed formed as the product of two 3-digit numbers.
then download the programs and take a look.
January 23, 2003: Andy Womack sent me a note with a new shorter solution to the Rally marble puzzle: 1 X Horizontal-Clockwise, 4 X Vertical-Counterclockwise, and 3 X Horizontal -Clockwise will replace the red marbles with blues in 8 single position moves. My previous best had been 9. Surely 8 is the minimum?.
January 30, 2003: Viewer Zebulon has been working hard, and with some success, at finding bugs in the Tangram2 program. In more complex tangrams, pieces sometimes could not be dropped where they should obviously fit. In the original version, for example, you cannot drop the parallelogram in the position shown in this figure from tangram file medium.tan. Placing it there will not help solve the puzzle, and pieces would always drop in their "correct" positions, but there's no logical reason that the piece should not drop in this location - now it will. (For the curious, the drop failed if piece being dropped shared a single point with a non-vertex border point of a solution piece.) The version posted today isn't perfect yet, but it is an improvement over the original.
February 4, 2003: It seems like I'm involved with a number of not-so-fun projects these days. So I took today to work on one that is going to be fun: an X-10 monitor and control application. X-10, if you are not familiar with it, uses house wiring to transmit control signals to and from devices. There is a two-way computer interface available which opens up possibilities for detecting movement and device usage and issuing commands to turn on lights, make announcements, sound alarms, etc. When a vehicle triggers our driveway alarm, the computer now announces "Someone is coming , run and hide!" There's still a ways to go, but the project did prompt today's posting EnumWindows in the Delphi Techniques section. The monitor program must converse with a terminal program which accepts and sends signals over a serial port. In order for the monitor program to start and stop the terminal program gracefully, it must be able to detect if the program is running. This program will accomplish that. One small step ....
February 5, 2003: While searching for sample code to identify running programs yesterday, I ran across this CPUSpeed program. As the name implies, run it and it tells you the speed of your CPU. Of course you probably know the speed of your processor, but some laptops automatically "underclock" and speed demons regularly overclock so there may be a purpose - besides being a simple bit of code that might get you as close to the hardware internals as you'll ever want to be
February 9, 2003: I've had an interesting exchange in the past week or so with a college professor who is trying to decode the names and phrases used by the Lilliputians in Jonathan Swift's book "Gulliver's Travels". He was looking for a version of our Decrypt program which would relax the dictionary matching requirements. I had thought previously about allowing one or more unmatched words (words not in the dictionary) when decrypting. Unfortunately, my current approach starts by decrypting the longest word in the message first on the assumption that there will be the fewest possible decryptions of this word and thus will prune the search quickly. If we assume that the longest word does have to be in the dictionary however, search time explodes! So it's back to the drawing board on that project. To make a long story short(er), I switched to an anagram approach and modified the Unscramble program to read a text file of names and phrases and produce a text file of possible anagrams. Whether it will help or not remains to be seen, there are phrases containing words like "king" and "elfin" .
Anyway, while doing all of this, I decided to re-post the WordStuff #2 program with some minor cosmetic issues corrected. Wordstuff #2 is a "wrapper" for four other programs: Decrypt, Unscramble, Word Completion (Crossword Helper), and Word Ladder. So if you haven't tried it before, take a look!
February
15, 2003: One of my kids got me a binary clock for
Christmas. It's cool, and I am even getting
pretty good at reading it. So here's a software
version of the Binary Clock with
some features that the hardware version can't match - it's easier
to set, LEDs (and background and labels) can be any color you
want, and you can set a "secret" time to test student's
ability to convert a binary time to decimal without getting a hint
from the clock on the wall! .
February 21, 2003:
I had added the ability to display date/ time messages in our Scrolling LEDs program a couple of months ago, but never got around to posting the change. This week a user requested the ability to display scrolling LED messages in a separate window, so I decided it was time to post this version incorporating both changes.
February 26, 2003: Two avid "Logic puzzlers" have been been giving my "Logic Problem Solver" program a workout for the past few weeks. The result is a a new version posted yesterday with a number of bugs fixed and a few significant enhancements. If you're into that sort of thing, check out this new version.
Gary Darby
http://www.delphiforfun.org
"I have failed over and over again in my life. And that's why I have succeeded." Michael Jordan (basketball player)
To subscribe or
unsubscribe from this newsletter, visit http://delphiforfun.org/newsletter.htm
35,500 home page
visitors!