The two real kickers I added today were the binary calcutions:

1&$c and 4&$A + 5

The first one checks if the first bit of the digit is used, so this is true for every odd number and false for every even number.

1 = 0 0 0 1 = true
2 = 0 0 1 0 = false
3 = 0 0 1 1 = true
4 = 0 1 0 0 = false

The second one is just like that. the variable $A kan be anything from 0 to 9. Because I needed a range of 4 digits to check I check against the 3rd bit(= weight=4). (3, 4, 5, 6) since my range starts at 3 but the first number with a false 3rd bit is 8 I need to add 5 to my number to check.

so if we continue the table above:
2 + 5 = 7 = 0 1 1 1 = true (third bit = 1) Not correct
3 + 5 = 8 = 1 0 0 0 = false
4 + 5 = 9 = 1 0 0 1 = false
5 + 5 = 10 = 1 0 1 0 = false
6 + 5 = 11 = 1 0 1 1 = false
7 + 5 = 12 = 1 1 0 0 = true (third bit = true again) Not correct

Does this make it any clearer?
_________________________
The Code is out there