CSC148H/A48H exercise — week 3


Important:

Light Switch Problem

I have a board of Lights, numbered 0,1,2,...,1023. Each Light can be either on or off. All Lights are initially off. Step 1: I flip all of the Lights starting at 0. At this point, all of the Lights are on. Step 2: I flip every second Light, starting at 0. At this point, Lights 0,2,4,6,8,... are off. Lights 1,3,5,7,9,... are still on. Step 3: I flip every third Light, starting at 0. So I flip Lights 0,3,6,9,12,... that is, if a Light is on, I flip it to off. If a Light is off, I flip it on. ... Step 1023: I flip every 1023'rd Light, starting at 0. So I flip 0 and 1023. Question: At this point, which Lights are on and which are off? To solve this puzzle, build a python program (in file Lights.py) with classes