Question: Using RUBY: There is a circle of 2 or more lights with a switch next to each light. Each switch can be flipped between two

Using RUBY:

There is a circle of 2 or more lights with a switch next to each light. Each switch can be flipped between two positions, thereby toggling the on/off state of three lights: its own light and the two lights adjacent to it. Initially, all the lights are off. Write a program in Ruby that will tell you how many switches need to be flipped for turning on all of the lights for a given number of lights in the circle.

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!