You are in the dark, and on the floor there are six shoes of three colors, and a heap of twenty-four socks, black and brown. How many socks and shoes must you take into the light to be certain that you have a matching pair of socks and a matching pair of shoes?
The Solution
Let c := the number of colors of socks and h := the number of colors of shoes. The number of shoes you have to take into the light is h + 1 (which is 4). The number of socks you have to take into the light is c + 1 (which is 3).
I've got a masters degree in computer science and over 10 years of experience building web-based systems using Java/J2EE, Ruby, Rails and PHP. I'm a strong believer in the effectiveness of Agile Methods. Read more »
Six Shoes and Twenty-Four Socks
The Problem
You are in the dark, and on the floor there are six shoes of three colors, and a heap of twenty-four socks, black and brown. How many socks and shoes must you take into the light to be certain that you have a matching pair of socks and a matching pair of shoes?
The Solution
Let c := the number of colors of socks and h := the number of colors of shoes. The number of shoes you have to take into the light is h + 1 (which is 4). The number of socks you have to take into the light is c + 1 (which is 3).