Sunday, May 9, 2004

 Delphi For Fun Newsletter #36

[Home]

Spring has sprung here in the mountains of Virginia, so programming will be on its summertime schedule.   It’s been an exciting couple of months, including a new grandbaby, Nathan, born on March  9th!   We’re heading out next week to see how much he’s grown in 2 months.  

 And the week after, we’ll be attending the Destination Imagination "Global" Finals in Knoxville, TN.   A young lady wrote to me some time ago asking about pendulums – an important element in the skit they are presenting.   She has kept me posted since then, and last month they won the South Carolina championship in their division!    I just can’t resist the chance to go down and see this thing in action when they compete in Knoxville. 

 There are a couple of  new programs this period: ”Missionaries and Cannibals”  puzzle ,  and a word puzzle  I call “Scrambled Pie".  Plus the usual fix-ups and enhancements including a 5/6 peg version of the Mastermind game and a "Crackerbarrel" version of Peg Solitaire.     Enjoy!

Here's the rest of What's New since last time:

  March 4,  2004:   My old business partner asked recently if I could do a  version of the triangular peg puzzle similar to those for in Cracker Barrel restaurants.   Getting down to one peg left is driving his wife crazy!  I re-posted a Peg Solitaire version today which includes it.  I didn't not redo  the drawing routines to draw an equilateral triangle, but you can play a right angle triangle version with 5, 6, or 7 holes per side. (If you can solve these, just mentally rotate the 5-per-side puzzle by 45 degrees and Cracker Barrel will be labeling you as a "Genius". )   Note that "Auto-solve" has not yet solved the "one peg left" 7-per-side version so I don't even know if a solution exits.  If you let your PC run it long enough to find out, let me know.

 March 6, 2004:  Sharp-eyed viewer, C. Doumar, spotted a bug in the auto-solve triangular puzzle code. It now finds quick  "1 peg remaining" solutions for the 6-pegs-per-side cases.  I reposted Peg Solitaire today with that fix.  7-pegs per-side  is still not so quick.

March  9, 2004:  It's a boy!  Just to let DFF viewers know that programming will take a back seat for the next week or two.   Somebody has to hold the new grandson  and, once in a while, it is even my turn!   I'll get back to e-mail responses and projects when the excitement dies down.  
   

 March13, 2004:  Grandma won't let me have the baby so I fixed a small problem in Intersecting Lines demo over in Math Topics.  Viewer Phil Hackett had pointed out earlier this month that testing parallel lines caused a "divide by zero" exception instead of a "Lines do not intersect" message - now fixed.  And Grandma's turn is up.  Thanks Phil. 

March 23, 2004:  We're home!  When Amy thanked us for helping out with the new baby,  I thanked her back for providing us one more chance to experience miracle of new life.  Trying writing a program to do that! 

I received an email last week from a beginning Delphi programmer asking for help with a program in which the user dragged colors to make  guesses of a secret pattern.   It triggered a question about how simple the drag/drop part could be.  The answer is in  this  Simple Drag Drop program.  OK, OK, to kill the suspense -  the answer is just two lines of user written code!   Surprised even me.     We may finish the rest of the puzzle this week - just for fun.

 

March 26, 2004:   A viewer today raised some question about the  Making Change program , which solves the number of ways to make change for $1 and some other making change problems.   (I think he thinks there are only 289 ways, but it wasn't entirely clear.)  In any event I ran version 2 of the program and couldn't even understand my description of the "Minimum coin set” problem.    I improved the problem description and changed the program to list a sample solution for all of the smaller sets of coins that can make change.  

March 28, 2004: I posted version 1 of a Drag Colors Puzzle today.  The idea is to guess a secret color pattern generated by the program in the fewest number of guesses.  The program is classified at the Beginners level since it has less than 50 lines of user written code.   It's analogous to Mastermind, except the only feedback given is the number of colors in the correct position.   It seems that this makes the game more difficult to analyze, at least I haven't been successful so far.  I suspect that similar pattern guessing games must have been analyzed and documented under other names.  Let me know if you locate or develop an optimum guessing strategy just to put me out of my misery.    (This version has pattern of 3 colors chosen from a palette of 4 colors  - an analysis would derive the best strategy for patterns of length M chosen from N colors.  Seemingly not a trivial exercise.) 

March 29, 2004: While proving to James the other day that there were really 293 ways to make change for a dollar, I needed to resort my output grid in descending order to match his format.  Here is an update to the Grid Quicksort program that will sort string grid columns in ascending or descending sequence.  (By the way, he had missed the 4 ways to make change that have more than 2 quarters.)  

April 2, 2004:  I decided to provide a print feature in my current puzzle project (Scrambled Pie) and to print the solution upside-down at the bottom of the page.   Using the "divide and conquer" strategy for problem solving, it seemed worthwhile to develop the inverted display and print code first.  Here is Test Inverted Text in the Delphi-Techniques section.  

I included a runtime fix for a Delphi 5 "bug" along the way -  "hard" line breaks are inserted into memo text at design time.   Guess I should go check D7 and see if the problem still exists.  But maybe if I procrastinate a while, some alert Delphian will send me feedback.   

April 7, 2004:  Here's a Scrambled Pie puzzle generator/solver.  Given four words, all missing the same single letter, find the letter and unscramble the words.  Mensa® Calendar owners will already have struggled with these.  The program will generate puzzles simple enough for me to solve up to those that I would think are nearly impossible.    And some, like the sample shown here,  look simple but may be tough.


 

April 16, 2004:  One of the neat things about running this website is hearing from people around the world.   While I was busy hiding and (and finding) Easter eggs this week, an email came in  from a German fellow who is teaching English in China!   He's using the Scrolling LEDs program to present vocabulary but wondered if the program could be modified to save his font and text settings from run to run.   Sure -  it's done Hans!      

April 25, 2004:   This week's offering is the Missionaries and Cannibals river crossing puzzle.   (That name is more popular than  "Cannibals and Missionaries"  by about a 3 to 2 margin according to Google.)    No animated graphics, but it does allow user play and of course the program can find all 4 solutions in a few milliseconds.
   

 

May 2, 2004:  My version of the classical pattern guessing game, Mastermind,  has been downloaded  a couple of thousand times since I posted it three years ago.   The objective for the code-breaker is to identify a secret peg pattern using clues provided by the code-maker.  Either the user or the program may play the code-breaker role.  The user is the code breaker in this screenshot (and is about win!)  

Based on user feedback,  I updated the program this week to allow user selection of number of pegs and colors and increased the maximum number of pegs in the secret pattern to 6.   Surprisingly,  the 5 or 6 peg case seems only slightly more difficult than with 4 pegs.   The program must work considerably harder, however,  to analyze 46,000 potential secret patterns instead of 1200!  

May 7, 2004:  A viewer found a small problem in  the Minimize to Systray demo program posted in Delphi-Techniques this week.    The demo shows how to minimize programs to an icon the "System Notification Area" rather than the taskbar.   I've  corrected  a problem with  "cannot switch sheets on a tabbed PageControl after restore from Systray" .  Writing the one line of code to fix it took about 5 seconds - finding which line to write took about 5 hours!  

I'm receiving about 5 emails per day now with virus attachments.   The  bodies have messages like "Important informations!”  or "Don't visit these web sites"  and often include reassurances like "Virus scanned and safe to open".  Right!  Maybe we should thank the virus senders for educating the public on the importance of acquiring a virus scan program and keeping it and Windows updated.  Microsoft says that 1.5 million copies of their "Sasser Worm Removal" tool have been downloaded, so there's 1.5 million users who have probably turned on Windows automatic update to keep it from happening again.    Seems like virus writers, "script kitties",  and hackers would be putting themselves out of business before long. 

Spam is of course the other daily annoyance -  I get 20 or so offers per day to refinance my house or buy drugs without a prescription or to enlarge some body part.    I'm sure that my spam load is minor compared to many, but it has bugged me.  I have a 30-day trial of "I HATE SPAM" installed now, and it looks like it will be worth the $20 cost.   Here's a link to a review of several "Spam Filters" from the current PC World magazine.     By the way, the PC World site will  put some "spyware" on your system.  Get freeware program "SpyBot" to get rid of it and immunize against future infestations.  Don't worry to much about this - if you have Spybot, you are immunized against it, if you don't have SpyBot, you already have dozens or hundreds of spyware programs running on your system.  Here's a Microsoft link explaining more and recommending SpyBot or Ad-aware software as solutions.  

 

Gary Darby
http://www.delphiforfun.org/

 

" Even if you're on the right track, you'll get run over if you just sit there."  - Will Rogers

 

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

75,000 home page visitors since Sept 2000.     197,000 programs downloaded in the past 12 months!