Here you will find daily news and tutorials about R, contributed by over 573 bloggers.
There are many ways to follow us - By e-mail:On Facebook: If you are an R blogger yourself you are invited to add your own R content feed to this site (Non-English R bloggers should add themselves- here)

The weekend puzzle in Le Monde this week is again about a clock. Now, the clock has one hand and x ticks where a lamp is either on or off. The hand moves from tick to tick and each time the lights go on or off depending on whether or not both neighbours were in the same state the previous time. Here is my R code that describes the evolution of the clock according to this rule:

Given the initial state (0,1,0,1,1,0,0,0,1,0,0,1), the question is to provide the state after one hour

> states
[1] 0 0 0 1 1 1 0 0 1 1 0 1

The next question is rather unclear: with a different number of ticks, is it possible to forecast the state of the clock one hour later? My answer is to run the R code with the appropriate value for ticks and observe the result, since the update rule is deterministic. For instance, here is the result for 18 ticks:

But I am sure this is not what the authors of Le Monde puzzle meant…