Delphi For Fun Newsletter #16
Sunday April 29, 2001
Delphi For Fun Newsletter #16
Thanks to Earl Glynn for letting me know that the links to programs mentioned in these Newsletters weren't working. They are copied from the What's New page of the www.delphiforfun.org website, where they do work but don't require fully expanded link addresses - the newsletter does. I've started using full link addresses, so they should work from either location.
By the way, Earl runs the best reference site I know of for programming things mathematical, algorithmical and scientific. Check him out at www.efg2.com.
Here are the "What's New" excerpts since last time.
April 20, 2001: We haven't had a game in a while, so here's intermediate level Token Flip. 16 tokens, black on one side and white on the other arranged on a 4X4 square board. The objective is to flip the fewest tokens to get all white sides up. The complication is that when you select a token to flip, adjacent tokens above, below, left, or right of the one selected also get flipped. User play and a program solution are both implemented.
The puzzles "auto-solve" is implemented using the previously posted TIntList integer list component to build a queue of configurations for a breadth-first search. In the process, I realized that the AddObject method had been omitted from the original posting. A corrected version is included with Token Flip source download and also on the original Delphi Techniques page.
April 25, 2001: Time for another beginner's program. Clock Angles has the job of calculating and displaying the angle between the clock hands given hour and minute values. 100 lines of code but only 60 user written (20 to calculate and display the angles and 40 more to display a clock face with the hands positioned properly.)
This program and the previous Token Flip program are both based on ACM programming contest archives. What a great source for programming problem material! ACM (Association for Computing Machinery) and IBM sponsor the contest annually for college students. Teams compete in regional competitions with winners going on to the World Finals. A couple of thousand teams from a thousand or so universities competed in the 2001 contest. 3-man teams have 5 hours to complete as many programmed solutions as possible from a set of eight problems. Delphi was available for use at the World Finals but I wasn't able to determine if any Delphi teams were entered. I doubt it since academia is hung up on C, C++, and now Java. By the way, St. Petersburg University (Russia, not Florida) finished first for the 2nd consecutive year and Virginia Tech. finished second. Way to go guys, even if you didn't use the best language. Flash! I just found a forum discussing world champion St. Petersburg University's wins and indicating that they are Pascal programmers! Alright!
I wrote Clock Angles with a self imposed one hour time limit to see if any of those old test taking skills remained. I did OK but decided that a time limit does take away a lot of the fun factor. The basic, non-visual solution took 30 minutes so I guess it's time up the level and maybe do a hard one in 2 1/2 hours.
April 29,2001: Here's the third ACM Programming Contest problem. In Chicken Crossing you get a file with information about the size, speed, lane, and time of arrival of some trucks and you must determine if the chicken safely crosses the multi-lane highway or becomes a candidate for a barbeque. This is the first, and probably the only, instance of a console application that you'll find here. Console applications run like the old DOS apps with text input and output, no mouse support , etc. All ACM contest programs run this way, for ease of scoring I suppose. (Or maybe just to make it easier on those poor C programmers.) The only math required for this beginners program is a little algebra and an understanding that speed=distance/time.
To subscribe or unsubscribe from this newsletter, go to http://www.delphiforfun.org/newsletter.htm
"If you don't invest very much, then defeat doesn't hurt very much and winning is not very exciting." -- Dick Vermeil - (Football coach)