14
0
Introduction
Suppose I have a list of integers, say L = [-1,2,2,1,2,7,1,4]. I like having balance in my life, so I'm happy to see it has as many odd elements as even elements. What's more, it also has an equal number of elements in all modulo classes of 3 that it has elements in:
[-1,2,2,1,2,7,1,4]
0 mod 3:
1 mod 3: 1 7 1 4
2 mod 3: -1 2 2 2
Sadly, for the modulo classes of 4 this no longer holds. In general, we say a non-empty list is balanced modulo N if it has an equal number of elements in all modulo classes of N for which this number is not 0. The above list L is balanced modulo 2 and 3, but unbalanced modulo 4.
The task
Your input is a non-empty list L of integers taken in any reasonable format. Your output is the list of those integers N ≥ 2 such that L is balanced modulo N, again in any reasonable format. The order of the output does not matter, but it should not contain duplicates.
It is guaranteed that there are only finitely many numbers in the output, which means precisely that not all elements of L occur an equal number of times in it. Examples of invalid inputs are [3], [1,2] and [0,4,4,0,3,3]. Notice that the largest number in the output is at most max(L) - min(L).
The lowest byte count in each language wins, and standard code-golf rules apply.
Test cases
[1,1,2] -> []
[1,1,5] -> [2,4]
[1,1,24] -> [23]
[1,2,3,2] -> [2]
[12,12,-4,20] -> [2,3,4,6,8,12,24]
[1,1,12,12,-3,7] -> [3,10]
[-1,2,2,1,2,7,1,4] -> [2,3]
[4,-17,-14,-18,-18,3,5,8] -> []
[-18,0,-6,20,-13,-13,-19,13] -> [2,4,19]
[-11,-19,-19,3,10,-17,13,7,-5,16,-20,20] -> []
[3,0,1,5,3,-6,-16,-20,10,-6,-11,11] -> [2,4]
[-18,-20,14,13,12,-3,14,6,7,-19,17,19] -> [2,3]
[-16,-9,6,13,0,-17,-5,1,-12,-4,-16,-4] -> [3,9]
[-97,-144,3,53,73,23,37,81,-104,41,-125,70,0,111,-88,-2,25,-112,54,-76,136,-39,-138,22,56,-137,-40,41,-141,-126] -> [2,3,6]
Some languages which automatically calculate the upper bound (Brachylog perhaps?) will have an advantage... – user202729 – 2017-12-03T15:18:50.530