There was a lot of extra information in that brain teaser. All you really needed was these two sentences:

Clearly 41 runs * 1210 feet = 49610 feet. The watch incorrectly said that I had skied 20,100 but had the correct number of runs.

So if I had looked after one run, the watch would have said 1210. After two runs it would have said 2420. After 10 it would have said 12100. Obviously that line of reasoning can’t continue indefinitely because by the time we get to 41 runs, the watch isn’t showing what we expect. So what happened?

The number is stored as a 16 bit signed integer. The maximum 15 bit number is 32,767. After reaching that number, the counter rolled over to 0 and kept increasing. 32,767+20,100 = 52,867. That’s close enough to the expected 49,610 to be reasonable. The difference can be accounted for by slight rises and falls in the run (it’s not perfectly smooth all the way down) and a little barometric pressure variation throughout the day.

That's my theory anyway. Until I check the watch just before 32,767 and then do it again and check just after 32,767, I won't be sure. It seems very reasonable though.

PingBack from http://msdnrss.thecoderblogs.com/2008/03/11/brain-teaser-answer-3/

PingBack from http://msdnrss.thecoderblogs.com/2008/03/11/brain-teaser-answer-3/

PingBack from http://msdnrss.thecoderblogs.com/2008/03/11/brain-teaser-answer-4/

I realize that you’ve had the watch for a couple of years, and this is the first you’ve seen this bug. And I also realize that it took you a 23 hour marathon ski session to find the bug. But for petes sake! The one job it has is to count a huge number of feet, and it rolls over at 32K???