Question: Computer Science - Python Programming A lot of switches I have a board of light switches, numbered 0,1,2,... ,1023 Each light switch can be either

 Computer Science - Python Programming A lot of switches I havea board of light switches, numbered 0,1,2,... ,1023 Each light switch can

Computer Science - Python Programming

A lot of switches I have a board of light switches, numbered 0,1,2,... ,1023 Each light switch can be either on or off. All switches are initially off Step 1: I flip all of the switches starting at 0 At this point, all of the light switches are on Step 2: I flip every second switch, 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 svitch, starting at 0 So I flip switches 0,3,6,9,12,... that is, if a switch is on, I flip it to off If a switch is off, I flip it to on Step 1023 I flip every 1023'rd switch, starting at 0 So I flip 0 and 1023 Question: At this point, which switches are on and which are off? Solve the Problem Your first task is to try to solve the puzzle using nothing but your own brain (and possibly a pen & paper) Can you figure out the pattern? (there's a way of finding the answer without actually walking through 1023 steps) No... really... Solve the Problem I'm sure half of you just jumped straight over the previous section to get to the "real" exercise. But really c'mon... give it a try A lot of switches I have a board of light switches, numbered 0,1,2,... ,1023 Each light switch can be either on or off. All switches are initially off Step 1: I flip all of the switches starting at 0 At this point, all of the light switches are on Step 2: I flip every second switch, 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 svitch, starting at 0 So I flip switches 0,3,6,9,12,... that is, if a switch is on, I flip it to off If a switch is off, I flip it to on Step 1023 I flip every 1023'rd switch, starting at 0 So I flip 0 and 1023 Question: At this point, which switches are on and which are off? Solve the Problem Your first task is to try to solve the puzzle using nothing but your own brain (and possibly a pen & paper) Can you figure out the pattern? (there's a way of finding the answer without actually walking through 1023 steps) No... really... Solve the Problem I'm sure half of you just jumped straight over the previous section to get to the "real" exercise. But really c'mon... give it a try

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!