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
Get step-by-step solutions from verified subject matter experts
