From New Scientist #3429, 11th March 2023 [link] [link]
“Why isn’t the sound working?”, Mum muttered as she hit the mute key on the remote control.
“You’ve probably got the wrong remote, Mum”, Sam said. “Remember, it’s the long, thin one for the television, the wide one for the set-top box and the little one for the speakers. Which one did you mute?”
“I can’t remember”, said Mum, as she got her thinking cap on to try to fix things.
To get sound, all three remotes have to be unmuted. Mum came up with the most efficient system for cycling through the possible combinations of muting and unmuting, and got to work.
What is the maximum number of presses needed if she wanted to be sure of getting the sound back?
[puzzle#212]
Like this:
Like Loading...
If just one of the devices is muted we can pick any remote and press mute/unmute.
If this gives sound were are done, otherwise we press mute/unmute again, to go back to the original state.
We then pick one of the remaining remotes, and press mute/unmute.
If this gives sound were are done, otherwise we press mute/unmute again, to go back to the original state.
We then take the final remote and press mute/unmute.
If this doesn’t give sound then the problem wasn’t that exactly one of the devices was muted.
So this solves the problem in 1, 3, or 5 button presses, and this is minimal.
This Python program shows that we cannot have a sequence of moves that is guaranteed to solve the problem in fewer than 5 presses.
Apparently the setter intended the three devices may be in any mute state (apart from all unmuted).
We can adapt the program to solve this scenario by changing line 11:
We then find a minimal sequence of length 7 that will resolve these situations in 1-7 presses:
Short answer: Gray Code.
It is used exacly for that: to minimise the number of switchings when cycling through all possible states.
Reminds me Duke Nukem 3D game which has switch operated doors (https://infosuite.duke4.net/index.php?page=ae_doors_d8) on some levels, where you need to cycle through different switch combinations to open it.