Tuesday, April 10, 2007

Binary search at home

Saturday I had to figure out which fuse to throw to cut the power to my upstairs bathroom. So I turned to a binary search algorithm.
After doing an exhaustive search of the right side of the panel and coming up with butkiss, I moved to the left panel. To minimize the number of basement to 2nd floor trips (I was alone), I threw the first 6 switches--exactly half of the total 12 switches. I ran up stairs and saw that that had done the trick. So I reset switches 4, 5, and 6. The light was still out in the bathroom. I was down to 3 switches in 2 tries!

Now came the tricky part. Do I reset 1 or 2 switches? Either way I figured I would have to make 2 more choices. So I did one. The light stayed out. On the next try I got lucky and reset the right switch. At worst I would have had one more resetting.

That's a total of 4 tries to find the right switch out of 12 possibilities. I wish I had thought of that when I was doing the right panel.

2 comments:

parsnipgirl said...

It's about damn time you're back! Plus I like your search algorithm. And now I know that it's called a binary search algorithm, which just sounds coo.

Anthony said...

You're watching WAYYY to much NUMB3ERS.

Tnanks for the 'Carmen' video. :)

Site meter

Search This Blog