First Mathematics Puzzles
I solve this Mathematics puzzle using Python Jupyter notebook. Using a few lines of code that simulate the opening and closing actions of the lockers I found these lockers that would be closed, while the rest of the lockers would be opened. Below are my codes for the problem: I first make a list of 1000 entry in Python to denote each locker space. I denote 0 is open and 1 is closed. Then, I wrote a double for-loop to simulate the actions of each student from 1 to 1000 opening and closing their respective lockers. The outer for-loop loop through each student from 1 to 1000. The inner for-loop loop model every student closing and opening their respective lockers. Then, we simulate the result and print out the lockers that are closed. The rest of the lockers would be opened.
Comments
Post a Comment