I started out the locker problem the same way I start most math problems: writing out some examples.
The leftmost column in the block below enumerates the students from 1 to 20 (that is the highest value I went to for my example, figuring it may be enough to illuminate a pattern). The top column enumerates the lockers starting from 1.
Beside that I have 20 "lockers" represented by - if the locker is closed and + if it is open. To the right of this I have some commentary of my thoughts for each row. It is important to note that because the subsequent students won't change the state of the lockers in line 20 because their values exceed 20.
0102030405060708091011121314151617181920
01 - - - - - - - - - - - - - - - - - - - - Student 1 touches all the lockers
02 - + - + - + - + - + - + - + - + - + - + Student 2 touches all even lockers
03 - + + + - - - + + + - - - + + + - - - + Student 3 touches all lockers that are a multiple of 3
04 - + + - - - - - + + - + - + + - - - - - Student 4 touches all lockers that are a multiple of 4
05 - + + - + - - - + - - + - + - - - - - + And so on...
06 - + + - + + - - + - - - - + - - - + - +
07 - + + - + + + - + - - - - - - - - + - +
08 - + + - + + + + + - - - - - - + - + - +
09 - + + - + + + + - - - - - - - + - - - +
10 - + + - + + + + - + - - - - - + - - - -
11 - + + - + + + + - + + - - - - - - - - -
12 - + + - + + + + - + + + - - - - - - - -
13 - + + - + + + + - + + + + - - - - - - -
14 - + + - + + + + - + + + + + - - - - - -
15 - + + - + + + + - + + + + + + + - - - -
16 - + + - + + + + - + + + + + + - - - - -
17 - + + - + + + + - + + + + + + - + - - -
18 - + + - + + + + - + + + + + + - + + - -
19 - + + - + + + + - + + + + + + - + + + -
20 - + + - + + + + - + + + + + + - + + + +So each locker is "touched" if the value corresponding to the student is a factor of the value corresponding to the locker.
Great! So we now know something about when lockers will be touched (i.e. when they're state will change from open to closed or closed to open). So what is it that influences whether a locker is closed, or in our picture above negative, or whether it is open, or positive?
Looking at the picture vertically now, we can see that a locker ends up closed (negative) if it has been touched an odd number of times, and open (positive) if it has been touched an even number of times. Given what we said earlier about factors, these number of "touches" are equivalent to the number of factors each enumerated locker has.
So which numbers have an odd number of factors and which have an even number of factors? If we need a hint we can look at the signs corresponding to line 20 above. The negatives correspond to lockers 1, 4, 9, 16, ... and voila! Perfect squares have an odd number of factors, while all other numbers have an even number of factors.
So after 1000 students (or any number of students for that matter) have had their turn, lockers corresponding to perfect squares will be the closed lockers and all others will be open. In the case of 1000 lockers 1, 4, 9, up to 961 will be closed.
Sidebar: In my original exploration I used 0s and 1s to represent the state of each locker but changed this to - and + to hopefully provide better intuition around odd and even factors. I also made an early mistake to the state of one locker which greatly confused me along the way when I had locker 20 as closed. When I thought more about the patterns going on I knew something went wrong with my example.

No comments:
Post a Comment