Friday, February 24, 2006
Delphi For Fun Newsletter #42
Another 3 months have flown by - I enjoy winter because I can stay inside and work on fun projects without feeling guilty about neglecting outside chores. Just an occasional trip outside to bring up a load of wood or fill the feeder for our wild turkeys. Plus once-in-a-while off property trips to visit grandkids or to see Dr. or dentist for preventative maintenance. Life is pretty good!
One of the traits of good problem solvers is persistence. That was brought home this week while I was working on Problem #115 from the Project Euler programming challenges at www.MathsChallenge.net. The gist of the problem is to find the shortest row of tile spaces (1 unit high by N units long) that would allow more than a million arrangements of tiles of size 1 x 50 or longer assuming each tile had to be separated from the others by one or more empty spaces. There are about 1800 programmers participating in Project Euler and, as of today, about 33 of us have solved all 117 problems. Of the 33, I'm the 30th. I'm either the least mathematical minded, or maybe just the oldest. Some of these guys solve these problems in minutes after they are posted. I worked on this problem for 2 or 3 hours each day for a week with no doubt that I would solve it eventually. Just think of the enjoyable hours that those guys missed by not getting to explore the byways and dead ends that do not lead to a solution! This is one of those cases, like most of the programs here at DFF, where the journey was more satisfying than the destination.
Here are the What's New items since November:
November 21, 2005: Version 2 of the game of Go was posted today. It does a better job of handling removal of multiple connected blocks of stones of the opposite color when a stone is played. And of disallowing "Ko" moves, situations where a a loop could occur with successive plays giving your opponent the same board he faced on his previous turn.
December 2, 2005: "Help, I have X and Y values in two list boxes and I want to chart the data. I am totally lost about how to do this!" That was the gist of the request that led to today's TChartDemo2 addition to the Beginners' page in our Delphi Techniques section.
December 10, 2005: Another user request this week, from a fellow who wanted an implementation of Keno, a casino game somewhat like an "Instant Lottery". The mathematics of the game are interesting. "If I select N numbers from a pool of 80, what is the probability that R of my N numbers will match numbers in a draw of 20 chosen randomly from the 80?"
I think I know -- you can too.
December 16. 2005: I've been resurrecting our old expert system, TurboExpert, this week. My long time engineer buddy is considering an oil industry consulting job and may have need for it. Maintenance costs for companies with lots of large rotating equipment (motors, pumps, etc.) are a big expense item. A system that can help intelligently diagnose vibration problems is valuable enough that it helped us both take early retirement. After retirement, it just happened to be easier for me to keep playing with computers at home than it was for him to find 20,000 hp motors to fix. I think he's missing it.
I recently started getting statistical summary reports about DFF again. It amazes me at the geographical distribution of our viewers. A typical day will have a couple of thousand hits from 80 to 100 different countries with about 40% from the USA.
December 19, 2005: Time for one more program before we head out for Christmas with grandkids. Here's Dice Odds, that calculates probabilities for rolling combinations of dice, either matched sets or sum of dots. It estimates probabilities by simulating a million throws and counting outcomes. I'll add the theoretical results when either I get more time, get smarter, or get some help from viewers.
December 31, 2005: Two more minor updates to close out the year:
A viewer found another bug in Intersecting Lines. Line segments which are co-linear (part of the same line) and where one line segment was entirely contained in the other were not identified as intersecting. Fixed now.
While correcting a typo in our Prime Factors 1 program, I noticed that I had promised a second version solving three specific prime number/factoring problems. I've added solutions for two of them today. The third program ("Find 10 digit primes with most 0's, 1's, 2's, 3's .... 9's") was tougher and a version may appear soon in Project Euler, a site with lots of interesting and challenging programming problems. I'll publish my solution here a month or two after that.January 9, 2006: I posted a new version of the TPrimes class today which has added methods to get the prime factors of a number in canonical form (unique factors and the number of times they occur) as well as a method to return the number of divisors and one to return an array of all divisors of any number up one trillion (1,000,000,000,000). Program Prime Factors 1 now has buttons to test these new methods.
January 10, 2006: Charles Doumar has made a few enhancements and fixed a few minor bugs in our "large integer" class, TInteger, in UBigIntsV2 unit and distributed as part of the DFF Library zip file, DFFLIBV04. More information and the test file for the class can be downloaded from the Big Integers test program page.
January 12, 2006: A viewer recently pointed out to me that the proposed revision to the wind-chill equation had been implemented, apparently shortly after my original posting in early 2001. The new equation is based on enhanced models of the effect of wind of exposed skin and verified by experimental results. A new version of Windchill was posted today which reports results based on both the old and new equations.
January 20, 2006: I finally got around to incorporating some requested enhancements to make Cutlist Version 3.1. Cutlist is a program for woodworkers which takes a list of required parts and a list of supply material, and tries to figure out the best way to cut the required parts from the available material.
January 23, 2006:
Inverted Text, Mirror text, Or Both?
January 28,2006: Charles Doumars, who's hobby is making my code better, has enhanced the TPrimes unit to handle primes up to 18 digits in length and do it rather efficiently both for finding prime factors and testing numbers for "primeness". I've modified Primefactors1 to let you enter and factor the new larger numbers. It identifies the 18 digit number 123,456,789,123,456,773 as prime in just under a minute on my laptop.
February 1, 2006: A new version of of DFF Library file, DFFV05.zip, was posted today. It includes a minor bug fix to the modulo function in the big integer class, TInteger, in unit UBigIntsV2. Program BigIntsTest illustrates the change.
The Mathslib unit is now officially included in DFFLibV05. MathsLib contains a number of math related procedures and functions which I've written over the years and collected there when I got tired of searching them out the second time I needed them. File DFFLibV05.txt lists the routines included. A few StringGrid procedures have been added to the DFFUtils unit to insert, delete, or sort rows. Also added were string functions to sort ascending, descending or rotate string characters and the missing Delphi function, StrToFloatDef, to convert a string value to floating point format or return a default value if the string is invalid.
February 3, 2006: I've been looking at some code written by a Croatian Engineering student for the past few days. (I love the fact that I get to communicate with Delphi users in so many different countries. ) Variable names in Croatian added to the challenge! Their instructor required the used of dynamically allocated records and pointers in solving a search problem and it brought to light a common memory leak problem - not releasing memory that you specifically allocate. Failing to do so in a recursively called procedure aggravates the problem with "stack overflow error" as a common symptom. It led me to write this small Memory Leak Demo program for the Beginner's page in Delphi Techniques section of DFF.February 7, 2006: One of the good suggestions not implemented in the latest update of our Cutlist work layout program was the ability to input dimensions and display results in fractional rather than decimal form. Users of the English system of measurement typically use plans and have tape measures that specify lengths in 64th of an an inch or some multiple (32nd, 16ths, 8ths, 4ths or 1/2). I've coded procedures to convert fractional form input strings to internal decimal form and internal floating point numbers to fractional formatted strings for display. Version 3 of Decimal to Fraction demo program, posted today, served as the test bed for these new procedures.
.February 10, 2006: Version 3.2 of our Cutlist program was posted today. It fixes a few bugs and adds two new worthwhile features: fractional representation of dimensions for input or display, and the ability to select a subset of the supply pieces to be considered in searching for solutions.
February 15, 2006: Every Olympic year, our Olympic Rings puzzle gets lots of hits. This year is no exception. Here's the entire email from a young lady (I'm assuming), who is upset because DFF didn't answer her question: "You need to show how to draw the rings. I was not satisfied you will never get my service again. i will not say goodbye" Who could ignore criticism like that? Here is a posting, in the Beginners page of Delphi Techniques that shows one way to do it using "ellipse" and "arc" procedures..
February 19, 2006: While writing last week's Olympic Rings program, I thought I would have to find the intersection points of the rings in order to complete the illusion of rings passing over and under neighboring rings. I turns out, I did not need the exact points. Redrawing 90 degree arcs in the appropriate quadrants was good enough., But it did plant the idea for a program investigate the math behind Circle Intersections which I posted today in our Math_Topics section.
or unsubscribe from this newsletter, visit
visitors since Sept 2000. 357,000
program downloads in the past 12
To subscribe or unsubscribe from this newsletter, visit http://delphiforfun.org/newsletter.htm
138,500 home page visitors since Sept 2000. 357,000 program downloads in the past 12 months!