demo-nested-loops-xmas-lights - I had fun with this...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
A Christmas Light Simulation Example You'd asked for more examples of nested loops. Here's a fun one: "250 strands of lights, 100 individual bulbs per strand, for a grand total of 25,000 imported Italian twinkle lights. .." [Clark Griswold, National Lampoon's Christmas Vacation ] Video Clip (as of 11/7/08) I've created a simulation based upon the scenario from the video clip above. Suppose we have strands of Christmas lights where if one bulb goes out, they all go out. We want to do the unpleasant task of checking every bulb to find where the problem is.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: I had fun with this problem, thus, rather than directly linking to the code, I'm giving it to you in two versions: Code to do the simulation . This is the short form that uses nested loops, as promised, and simulates checking for the burned out bulb in each of the 250 strands of lights. Enhanced code, with analysis. This version takes those results and adds a bit of probability theory to analyze the results of the experiment. (An extension is proposed in the documentation, too.)...
View Full Document

This document was uploaded on 02/10/2011.

Ask a homework question - tutors are online