# Most Difficult Riddle I've Heard [duplicate]

My friend told me this riddle, and I have been struggling for weeks to find the answer.

Riddle:

You are in a circular room, the size doesn't matter. Meaning, the room could be 5 feet in circumference or billions of miles in circumference. There are lights periodically, but evenly placed in the room with switches that can turn them on and off, however, the lights originally start off in an either on or off position, in a random order. You can walk anywhere in the room, but you can only see the 4 or 5 lights in front of you (you can't see every light in the room at the same time). You don't need to find how many lights are in the room, but, what is the METHOD for finding out how many lights there are?

Notes:

You can't break the lights or spit on walls or take off your clothes to mark your location in any way possible. Also, the fact that they are lights is NOT important. It's important that it's a binary code that can be a random sequence of 1's and 0's. It's also NOT important that it's a room, but it is important that it is circular. For example, it could be a table with pennies periodically placed around the edges with them faced on heads or tails. However, it's easier to imagine it as a room. Since it's binary, you also have to assume that there is any possible combination, and the method of just walking around the whole room and counting and turning on all the lights won't work, because it's possible to believe that you have reached the end when you reach a random stretch of lights that are already turned on.

I think it's pretty difficult.

Happy Thinking!

If you start at one lamp (0) change it's state and count it, then just look at the state of the next one, and change the state of the previous one (-1) and count it, and look at the state of the one before (-2) for later.

then

look at the next one (+1) if it has changed, if yes, stop, there are only two lamps, if not, look at the state of the -2 lamp, and change the +1 lamp and count it. look at the +2 for later and go back to seeif -2 lamp changed state, if so, just stop and there are three lamps.

basically

going back and forth like that will easily let you know how many lamps are in the room. the exact number you changed the state of.

also you can be faster :

if the lamp you're supposed to switch (say rightmost) is not in the same state as the one on the other side, they is no need to go back to the start to see if the leftmost has changed, just continue until the lamp you switch is in the same state as the laftmost for example.