I have an int array with 4 numbers that are sorted ascendingly.
I want to find out whether these numbers match this rule:
1, 2, 3, 4 or
5, 6, 7, 8 or
9, 10, 11, 12 or
13, 14, 15, 16
etc.
They cannot be
2, 3, 4, 5 or
4, 5, 6, 7 or
23, 24, 25, 26
etc
So they must be in a sequence but only in these 4-groups!
I tried to add all numbers (for example 1+2+3+4) and do the sum modulo 12 and the result is always 10, 2, 6, 10, 2, 6, etc. My idea was to check if the result is one of these three numbers 2, 6, or 10.
But it can’t work because for example (17+18+19+20)%12 is 2 which is legit but for example (2+3+4+5)%12 is 2 too but it’s not legitimate so it’d be a wrong result.
Let the numbers be
The rule is