This is a javascript implementation of Popular Mechanics Riddle of the Week #30.

You're in a room (belonging to Cthulu 🐙, as it were) with seven candles in a circle, on a table, in the middle of the room. The goal is to blow out all candles in the least number of moves.

When you blow out one candle in the circle, the two adjacent candles are extinguished as well. If you blow on a candle that has already been extinguished, it will relight. And if there is an extinguished candle next to the one you blow on, it also will relight.

To put it another way: When you blow on a candle, it—as well as the candles on either side—will change from lit to unlit, or vice versa.