Technology

Can You Solve the ‘1,000 School Lockers’ Riddle?

July 5, 2016 | Julia Kafato

Lockers in a school hallway
Photo credit: Brett Levin/flickr (CC BY 2.0)

It’s less complicated than you might think.

A school has exactly one thousand lockers, numbered from 1–1000, as well as one thousand students. Each year, the principal has closing ceremonies on the last day of school, during which she enlists the help of her students to close up the school’s lockers.

She assigns each student a number, and asks him or her to help her one by one. These are the instructions she gives each of the students.

SEE ALSO: Can You Determine the Rule in this “Intelligence Test”?

Student #1: Go to every locker and open it.

Student #2: Go to every second locker and close it.

Student #3: Go to every third locker. If it is closed, open it, and if it is open, close it.

Student #4: Go to every fourth locker. If it is closed, open it, and if it is open, close it.

This goes on until Student #1000 is finished.

After the closing ceremonies are finished, the principal walks through the school and closes each locker that is left open. How many lockers will the principal close?

Hint:

Test it out with only ten lockers and ten students and see if you can find a pattern.

Solution:

The principal only needs to close the lockers whose numbers are perfect squares. This means the solution is as easy as finding the square root of the highest possible perfect square within 1000.

        31*31 = 961

        32*32 = 1024

Therefore, 31 is the number of lockers the principal has to close.

Shown below is the solution with ten lockers and students.

X=Closed locker

O=Open locker

Here is what happens to the lockers from the first to the third student…

1

2

3

4

5

6

7

8

9

10

O

O

O

O

O

O

O

O

O

O

O

X

O

X

O

X

O

X

O

X

O

X

X

X

O

O

O

X

X

X

And by the tenth student…

O

X

X

O

X

X

X

X

O

X

The lockers left open after the tenth student is finished are lockers 1,4, and 9 — the only three perfect squares below 10.

The solution might become more obvious if you look at a specific locker and add together the number of students who have opened it and the number of students who have closed it.

The sum is equal to how many factors the number of that locker has. Each time a student opens or closes a certain locker, it is implying that the number assigned to the student is a factor of that locker number.

Since the lockers are closed to begin with, any time a locker number has an even number of factors, it will end up closed. Numbers with an odd number of factors will end up open. All perfect squares have an odd number of factors, which is why the lockers with these numbers end up open, while others end up closed.

Was that too easy for you? Try a harder one here.

h/t: pzzls.com

Hot Topics

Facebook comments