This is a little brain teaser of a R problem I trying to code.
Lets say you have 15 candles on a table. In three different rounds you will either light the given candles, or put them out, based on whether the candle is already lit or not. So if the given candle is already lit, then your action will be to put it out. On the other hand, if the candle is not lit, then your action will be to light it up.
Initially none of the candles are lit.
Firstly, you will light up every second candle, so candle number 2 till 14.
Secondly, you will light up/put out every third candle.
Lastly, you will light up/put out every fifth candle.
In the end I would like to know which candles are lit up.
I have created a data frame with the two variables. The number of candles, and a binary variable, stating whether the candle is lit or not.
I am able to solve this manually with three different if-statements, but I would like to do it with less code. Any suggestions on how I might do it?