SANTA.BAS February 2002 by Marc Kummel aka Treebeard. Contact mkummel@rain.org, http://www.rain.org/~mkummel/ What is SANTA.BAS? -------------------- SANTA is a small BASIC program I wrote to solve an interesting stumper about Secret Santa gift exchanges: At Dunn Middle School, we play "Secret Santa" for the holidays. We write our names on slips of paper and put them in a hat, about 20 kids per class, and each student draws a secret name. On the last day of school before vacation, we present our small gifts and homemade cards. Someone presents their gift to start, then the recipient, and so on until we're done. This year the 6th and 8th grades went through their classes one by one, but the 7th grade gift exchange broke twice when a student was called who had already gone. What is the probability of getting through a chain of 20 names unbroken? What about n names? For more info and links, check out my Secret Santa stumper (21 Dec 2001) on my Stumper Web page: . Using SANTA.BAS ----------------- SANTA is a simple DOS program. Run it in DOS, or a Command session in Windows. It asks you to enter a number of people in the gift exchange. Just press return to exit. It also asks if you want to save the results to the text file SANTA.DAT, which can then be imported into a spreadsheet like Excel. Warning, big numbers take a *long time* to calculate! Start small and work up. The Files: ----------- I wrote this program to solve a stumper. You'll have to study the source code for more info. I wrote it using MS Basic PDS v7.10, but it should work with any version of QBasic, QuickBasic, or PDF. SANTA.EXE DOS executible to partition a number SANTA.BAS BASIC source code SANTA.DAT Results for n=1 to 11 README.TXT This file TBVAULT.TXT Treebeard's Basic Vault info Conditions: ------------ This program and source code are yours to use and modify as you will, but they are offered as freeware with no warranty whatsoever. Give me credit, but do not distribute any changes under my name, or attribute such changes to me in any way. You're on your own! If you find this program or code useful, then let me know what you do with it, as a courtesy to a fellow programmer who still hacks for fun and glory. Any suggestions or comments will be much appreciated. Send comments and fixes to: Marc Kummel aka Treebeard mkummel@rain.org http://www.rain.org/~mkummel/ http://www.treebeard.org/ For more interesting Basic software with source code, check out Treebeard's Basic Vault at .