james5000 you have errors in your calculations.
Use this code:
import math
KEY_SIZE = 5
ONES = 2
n = KEY_SIZE - 1
r = ONES - 1
combinations = math.factorial(n) // (math.factorial(r) * math.factorial(n-r))
print("KEY_SIZE =", KEY_SIZE)
print("ONES =", ONES)
print("Combinations:", combinations)
A simple example for KEY_SIZE = 5
ONES = 2
number of combinations 4:
10001
10010
10100
11000
ONES = 3
number of combinations 6:
10011
10101
11001
10110
11010
11100
ONES = 4
number of combinations 4:
10111
11011
11101
11110
total combinations 14
Let's say we are looking for the key 10111. You do not know how many units the key contains and to find this key by your method, you will first have to sort through all the ONES = 2, then all the ONES = 3, and only at step 11 will the desired key be found. If you search for the same key by a simple sequential search, it will be found at step 7, that is, faster than your method. Your method proved to be worse than a simple sequential search, in a 66-bit key your method will work for eternity....