0:00
Hello.
00:01
For problem 21, you're solving a sort of locker puzzle where you're told that all of the lockers start closed on the first day.
00:11
The first student comes in and opens every locker.
00:17
And then the second student comes in and closes every other locker.
00:22
And then the third student comes in and changes every third locker and so on and so forth.
00:28
And you want to write a program that will.
00:31
Tell us what the locker states are at the end of 100 students going through.
00:39
So first we need to create our lockers.
00:42
So we will create a list lockers, which is 100 elements long, and every element in that list is just false to start with because all of the lockers start close.
00:56
And then we're going to iterate through each student.
00:59
So for s in range 100, because there are 100 students, we then need to iterate through each locker to determine how each student will affect each locker.
01:10
So for l in the range, s to length of lockers, and we start at s because the student will start at their own locker.
01:22
So the second student starts at locker two, the third student starts at locker three, and so on and so forth.
01:28
But they then all go through to the final locker.
01:32
And then we have our conditional statements here indicating what to do.
01:36
So if the locker is true and because the lockers, the student is also only going to interact with lockers that are multiples of their number...