Delphi For Fun Newsletter #45                                                April 2, 2007

 

Spring is finally here (hopefully).  We had a whopper of an ice storm last month that left us without power for3 days and I'm still clearing broken trees from  the trails.  Virginia is directly between the northern states that get mostly snow and the southern states that get mostly rain.   But that also means that it is mostly not too hot in the summer and not too cold in the winter so we can live with an inconvenient ice storm every 10 years or so.  

 

We have over 800 subscribers this quarter and I'm still searching for a usable mail list manager.  We're testing a new one this time, so apologies in advance if things aren't perfect.  (Always nice to have something else to blame!)     

 

Here are the programs created or enhanced in the spare hours since our last newsletter, while the weather was nasty but the power on :   

 

January 7, 2007:  We are back from our holiday travels.  I'm trying to catch up on the emails and to lose the 5 pounds gained in the last half of December.    One of the interesting emails received was from Claude Dellacherie., a French mathematician preparing a talk on the 15 Puzzle.  Version 3.1  was posted today with a few of his good suggestions for program enhancements. 

 

January 10, 2007:   Peg Solitaire has apparently made it to cell phones these days.  Viewer Bart wrote asking for help in solving this game on his phone.  It turns out that this is hardest solvable one I've seen so far.  I didn't find any shortcuts but Peg Solitaire Version 3 finds a solution for one peg left in the center hole in about and hour after trying 4.3 billion moves!    I added Bart's Board as one of the program's game choices if you want to try your hand at it.


 

January 14, 2007:  

A new version of our UGeometry unit with a 3 new routines and a couple of bug fixes was posted today.  Version 3 of the Geometry test program allows you to draw arbitrary polygons and inflate (or deflate them).  The area of the polygons created is available as a side effect of the calculation.   The most difficult part of the calculation is one that would be simplest for a human, determining which way to move the edges as we resize the polygon.   The computer program needs to know whether to move each edge left or right, but this depends in which direction the line was drawn. (To make a polygon larger, we need to move each edge to the left if it was drawn clockwise, but right if it was drawn counterclockwise. )  The easiest way I found to determine this was to use a side effect of a common algorithm which calculates the area of a polygon.   Area is negative for clockwise polygons, positive otherwise.  
 

January 18, 2007:  The DFF Library zip file, DFFLibV09,  was reposted tonight with a small bug fixed in UBigIntsV2, the big integers unit to correct a bug which could change the sign of the divisor after divide operations when the divisor was large.  Also corrected  a bug in the Exp(x) (exponential function, ex)  in the UBigFloatV2  (large floating point numbers) unit which caused zero divide exceptions for values of x between 0 and 0.3.

20 moves to solve

Oh, and I also posted Version 3.2 of the 15 Puzzle program. (V 3.1 was posted on January 7).   Claude Dellacherie has been giving the program a good  workout and uncovered about a dozen bugs that I have fixed.    I haven't heard from him in a day or two so maybe he's running out of bugs to find  (or given up :>).   


January 25, 2007:  A grandson recently had a complaint that my cannon  simulation allowed the cannon ball to magically pass right through the barrel on its way to the ground if the shot was weak.   I decide to fix it and had a fun week or or so exploring the implications.  Think you know at what angle a projectile must be fired to achieve maximum range?  What if the projectile is linearly constrained for the initial part of its flight?   Cannon Balls  V3 provides at least a partial answer.

February 1, 2007:  An update to our Astronomy Demo program last night adds "twilight" times to the sun position statistics.  The are three varieties (Civil, Nautical, and Astronomical) defined for different purposes, all relative to the angle of the sun below the horizon.  

February 7, 2007:   New versions of our big integers and and big floating point arithmetic classes were posted today in an updated version of the library zip file, DFFLibV10.    Aside from general cleanup, the big integer unit, UBigIntsV3,  contains new "divide with remainder"  procedures illiustrating that there is more than one way to define quotient and remainder when doing integer division.  See BigIntTest page for more information.  For large floating point unit ,UBigFloatV3, more cleanup and a new definition of the Round function which uses a parameter to specify the "round to" point relative to the decimal point location.  See BigFloatTest for more info on this. 

February 12, 2007:  Here is a new version of the "Spring Mass" simulation program.  Several fixes and enhancements have been applied. 

February 14, 2007:  Happy St. Valentine's Day to all the female viewers.   For the guys, remember to get her something that tells her how you feel., even if it's only a card.     

I listen to the "Car Talk" radio program on National Public Radio each weekend when I can.   I also subscribe to their weekly Puzzler newsletterA recent one involved a shootout where three mutual enemies agreed on rules for a 3-way "duel".  The question was about  choosing the worst shooter's  strategy to maximize his chances of survival.  Car Talk Shootout implements  a Monte Carlo simulation to answer the question including the best strategy (which happened not to be in my original set of choices at all).

February 18, 2007: Three programs have had minor updates in the past few days:

February 26, 2007

My whistle

and its (correct) spectrum

A significant correction was posted today to our Oscilloscope4 program (Version 4.2.2).  The spectrum analyzer function had displayed false overtones due to an error I made when adapting the original Fast Fourier Transform (FFT) code From Borland's Turbo Pascal version.

 .


      

   

 

 

March 2, 2007:  Version 1.3 of SciGrapher, our scientific graphing application was posted today.  The program is fairly flexible at drawing user defined curves.  This version adds the option of defining named constants to be used in the expressions defining the curves.  A new included sample graph, GatewayArch.grf, illustrates by drawing an approximation of the shape of the Gateway Arch in St. Louis, Missouri.  It's an inverted catenary curve,   a shape also used for pottery kilns to minimize stresses as the structure expands and contracts with temperature changes.   "Catenary" by the way is derived from the Latin word for chain and is the shape assumed by a chain suspended from its ends.  



March 7, 2007:  Happy Birthday to me!  68 today and still kicking! Good family, good food,  good books,  a good computer, even good weather.  Life is good.

Last week's Scigrapher update led to another catenary related program today in our Math Topics section. Square Wheels and Catenaries animates rolling a square wheel smoothly over a catenary roadbed.   Newton's Method was used to help design the road plus some other good math stuff.  

 

 

 

March 10, 2007:  Due to popular demand (3 requests this year :>), I finally added a "Donate" button to the website.  I tried to test it by donating $5, but PayPal doesn't like the idea of donating to yourself.  So if anyone happens to try it  and encounters any problems, please use the feedback link on any web  page to let me know.  Thanks.

 

March 14, 2007:

 One of my standard problem solving techniques is "Divide and Conquer".  If you can solve one piece of a large problem, you have not only reduced the size of the larger problem, but have gotten the psychological boost of having completed something as a bonus!   Here is Test Draw Rods, a program posted in the Delphi Techniques section, which contains  classes to draw cylinders that are divided into  segments with their length's labeled.  The components will be used to display results of a forthcoming program which solves the Cutting Stock Problem (look it up :>).   

March 15, 2007: Here's a quickie; an example of how  much dumber are computers than humans.  Or, more accurately, how difficult it is to make a program (e.g. a Delphi control) emulate human behavior.   Combine this with a user (me) making the error of setting parameters in the wrong order and we have discovered yet another way to create a "bug"

A program called Allwords,  on the Beginner's page in our Delphi Techniques section takes user input words and outputs all unique permutations of the letters in the range from 1 to word-length.   The control which specifies the maximum number of letters to permute is a TUpDown "spinner" control which has properties Position (the current value and the one which the user can change) and Max (the largest value which may be set).  For each letter entered, I wanted to set both Position and Max to that new word-length value. For the first letter, all is well, but.... when the next letter is entered and I try set Position to "2" (greater than Max value of "1"), the command is ignored without any warning!   When  I then set Max to Position, thinking that Position has just been changed, neither value has changed  and the maximum number of letters to permute stays stuck at 1 regardless of the length of the word entered.  The  fix is easy, just set Max before Position and all works as intended.       

 

 

March 22, 2007:

1-1 
 2-1 
 2-2 
 3-1 
 3-2
  3-3 
  4-1  
 4-2  
 4-4  
 5-1  
 5-2 
  5-3  
 5-4  
 5-5

The outlines have been removed from a set of dominoes which exactly fill a  rectangular board.   Given a list of the dominoes removed,  your task is to figure out where they belong on the board.    Here's the Domino Puzzle program for you to give it a try. 


April 1, 2007:  Here is my crack at solving the Cutting Stock problem:  how best to cut parts that only vary in one dimension, length or width, from stock that comes in lengths at least as long as the parts required.   Those giant rolls of paper you've seen on "How It's Made" TV shows often need to be cut into narrower widths for specific applications.  Manufacturers, distributors, or commercial users of wire, pipe, dimensional lumber, etc. often face a similar problem.  And they lwant to do it in such a way  that makes the best use of available stock. It made an interesting programming exercise and contains some interesting mathematics, at least conceptually within the grasp of us mere mortals. A sample solved problem is shown at right.

  



Gary Darby

http://www.delphiforfun.org/


"I hear and forget. I see and remember. I do and understand." - Confucius (551 BC - 479 BC)

"We are more ready to try the untried when what we do is inconsequential.  Hence, the remarkable fact that many inventions had their birth as toys. -- Eric Hoffer


To subscribe or unsubscribe from this newsletter, visit http://delphiforfun.org/newsletter.htm

185,000 home page visitors since Sept 2000.      360,000 program downloads in the past 12 months!