Imagine a countable infinite amount of empty rooms. When an infinite amount of guests come, they occupy the 1st, 3rd, 5th...(all odd) empty rooms. Therefore there's always an infinite amount of empty rooms, and occupied guests needn't move when new guests come.
- - - - - - - - - - - - - - - - -
1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
1 2 1 - 1 2 1 - 1 2 1 - 1 2 1 - 1
Same group of guests would leave together, so if group 1 leave, it results in
- 2 - - - 2 - - - 2 - - - 2 - - -
Notice that some rooms turn empty, so if another group of infinite guests come, it results in
3 2 - 3 - 2 3 - 3 2 - 3 - 2 3 - 3
Now room 1,2,4,6,7,... are occupied while 3,5,8,... are empty.
Input
Given a list of moves(aka. some group join or some group leave). All join requests are labeled 1,2,3,... in order.
You can also choose to not read the joining label or not read join/leave value.
Output
The shortest repeating pattern of occupied/empty.
Test cases
[] => [0]
[+1] => [1,0]
[+1,+2] => [1,1,1,0]
[+1,+2,-1] => [0,1,0,0]
[+1,+2,-1,+3] => [1,1,0,1,0,1,1,0]
[+1,-1] => [0]
Shortest code wins
10
and01
are different(01
should be impossible) \$\endgroup\$[+1,+2,-1,+3] -> [3,2,0,3,0,2,3,0]
) \$\endgroup\$