Solve in python language
Problem Description:
A school has 100 lockers and 100 students. All lockers areclosed on the first day of school. As the students enter, the firststudent, denoted S1, opens every locker. Then the second student,S2, begins with the second locker, denoted L2, and closes everyother locker. Student S3 begins with the third locker and changesevery third locker (closes it if it was open, and opens it if itwas closed). Student S4 begins with locker L4 and changes everyfourth locker. Student S5 starts with L5 and changes every fifthlocker, and so on, until student S100 changes L100.
After all the students have passed through the building andchanged the lockers, which lockers are open?
Write a function "main" to find your answer. The program shoulddisplay the answer like this:
Locker x is open
Locker y is open
…
Locker z is open
(Hint: Use an array of 100 boolean elements, each of whichindicates whether a locker is open (true) or closed (false).Initially, all lockers are closed.)
Solve in python language Problem Description: A school has 100 lockers and 100 students. All lockers are closed on the f
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am