Recently I posted a question about Diffy games which has gone unanswered. Thats fine, the question is really hard, but I would like to make an easier question about Diffy games so that we can get the ball rolling.
How Diffy works
Copied from Find Diffy Games
The Diffy game works like as follows: You start with a list of non-negative integers, in this example we will use
3 4 5 8
Then you take the absolute difference between adjacent numbers
(8) 3 4 5 8
5 1 1 3
Then you repeat. You repeat until you realize you have entered a loop. And then generally the game starts from the beginning again.
3 4 5 8
5 1 1 3
2 4 0 2
0 2 4 2
2 2 2 2
0 0 0 0
0 0 0 0
Most games end in a string of all zeros, which is considered to be a lose state, but a rare few games get stuck in larger loops.
Task
Given the starting state of a Diffy game determine whether or not the game eventually reaches a state of all zeros. You should output a Truthy or Falsy value for each of the two states. Which corresponds to which does not matter.
The goal is to minimize the number of bytes in your source.
1 1 0
is periodic, so42 42 41
is such a state. \$\endgroup\$ – Greg Martin Apr 12 '17 at 18:11n
is odd, the game doesn't go to zero unless all the numbers are equal. If the length is a power of 2, it always goes to zero. \$\endgroup\$ – xnor Apr 12 '17 at 21:00n
elements and maximumm
takes at mostn * bit_length(m)
steps. So,n*m
is also an upper bound. A stronger upper bound ist(n) * bit_length(m)
, wheret(n)
is the largest power of 2 that's a factor ofn
. \$\endgroup\$ – xnor Apr 12 '17 at 21:10