Subscribe to Windows IT Pro
October 18, 2005 12:00 AM

The Logical Puzzle

SQL Server Pro
InstantDoc ID #47753
Rating: (5)

Solution to October's Puzzle: Alternating Lamp States
In last month's puzzle, there were 100 lamps arranged in a row that were called lamp 1, lamp 2, lamp 3, and so on. All lamps were originally turned off. Each lamp had a switch that alternates its state (on/off). One hundred people (person 1, person 2, person 3, and so on) were given the following mission: Go to each nth lamp and alternate its state, where n is the person's number. So person 1 alternated the state of lamps 1, 2, 3, and so on. Person 2 alternated the states of lamps 2, 4, 6, and so on. What's the state of the lamps after all 100 people finished their missions?

The solution to this puzzle is mathematical in its heart. Integers that have an integer square root (e.g., 1, 4, 9, 16) have an odd number of divisors. For example, 9 has the divisors 1, 3, and 9. All other integers have an even number of divisors. For example, 10 has the divisors 1, 2, 5, and 10. The reason for the difference is that an integer with an integer square root can be formulated by multiplying a number by itself, so you don't count the same divisor twice. The formulation of all other numbers is always done in pairs of different divisors: 1*10, 2*5. Thus, all lamps in positions that have an integer square root will end up in the opposite state to the one they started with, while all other lamps will stay in their original state.

November's Puzzle: Cutting a Stick to Make a Triangle
This month's puzzle is combinatorial. You cut a stick in two random places. What's the probability that you'll be able to form a triangle out of the three pieces?

Related Content:

ARTICLE TOOLS

Comments
  • TOBY
    7 years ago
    Nov 15, 2005

    I posed the problem to my mother and she came up with a slightly easier analysis. Again, we're going to double an integral (and it will work out to be a similar integral, but the process is slightly easier to understand). This time we'll assume that x is the length of the shorter stick after the first, random, cut. So we're integrating from x equals 0 to 0.5 and then doubling the result. Now, if the first cut is in the first half of the stick, we figure out where the second cut can go such that we can still make a triangle. The second cut can't be before 0.5, because then the "last" piece would be longer than 0.5. However, the "middle" piece can't be longer than 0.5, so the cut can't be after x + 0.5. So the range for the second cut is from 0.5 to x + 0.5, and the probability of making the cut in that range (given that you could cut the sticks anywhere) is x!

    Thus, the probability that you can make a triangle is twice the integral of x from 0 to 0.5. The latter is 0.125, thus the probability is 0.25.

  • TOBY
    7 years ago
    Nov 10, 2005

    I agree with your initial analysis. However, I don't think 50% is the right answer. My initial analysis was wrong (I created a simple simulation in Excel to generate a lot of random tests quickly so I could validate my intuition).

    Here's my analysis. The first cut is completely random. As a result, our analysis is equivalent to twice the integral from 0.5 to 1 of the probability that we will end up with one stick that is 0.5 or greater given that the longer stick is the length from 0.5 to 1.

    Once we have a longer stick of length x, the first probability is that we will cut the shorter stick. That probability is 1-x. The second probability is that given the longer stick, we will never the less cut a stick longer than .5 out of it. If you visualize the cut, there are two ranges where you could make that cut - one at each end of the stick. The length of each range is x-0.5. The probability that you will make the cut in each range is (x-0.5)/x, so the probability that you will end up with a stick longer than 0.5 if you select the longer stick for the cut is 2*(x-0.5)/x. Of course, that gets multiplied by the probability that you will pick the longer stick, which is x (since the probability you would pick the shorter stick is 1-x).

    So, the answer is 2 time the integral from 0.5 to 1 of:

    1-x + x*2*(x-0.5)/x

    which is

    1-x + 2*(x-0.5)

    which is

    1-x + 2x-1

    which is

    x

    The integral from 0.5 to 1 of x is x^2/2 evaluated at 1 minus the same evaluated at 0.5, which is 0.5 - 0.125, or 0.375, but then we still have to double that (remember that we have to account for switching the sticks), which gives us 0.75, or 3/4s! Or, rather, the odds of ending up with three pieces that make a triangle are only one in four!

    I'm sure there's an easier way to do this, though.

  • MARK
    7 years ago
    Nov 04, 2005

    Sorry, my line breaks disappeared -
    So:
    x < y + (1-x-y);
    x < 1-x;
    2x < 1;
    x < 1/2;

  • MARK
    7 years ago
    Nov 04, 2005

    Sorry, my line breaks disappeared -
    So:
    x < y + (1-x-y);
    x < 1-x;
    2x < 1;
    x < 1/2;

  • MARK
    7 years ago
    Nov 04, 2005

    You cut a stick (of length = 1 unit) into three pieces randomly. You can only make a triangle out of them if the longest piece (x) is LESS than the combined length of the other two pieces (y and (1-x-y))

    So: x < y + (1-x-y)
    x < 1-x
    2x < 1
    x < 1/2;

    Therefore, the longest piece has to be less than half the length of the whole stick. You have (just under) a 50% chance of cutting a piece too long. (If it is exactly 1/2 the length, I wouldn't count that as a triangle.)

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.