More arithmetic support for "zero-agnostic" numbers.
This class optimizes the common search computation: given this subset of
cords, can I make a sum which is present in the full set of cords, and
if so, which cords could be sums?
Create the set of "possible answers":
>>> cords = Possibilities.create([9,18,90,180,181,222,635])
>>> str(cords)
'[9, 18, 90, 180, 181, 222, 635]'
Find the sums which can be made (note that zeroes are elided in the sums):
>>> sums = tsum([116,118,2436,4440], cords)
>>> list(sorted(sums))
[90, 180]
>>> list(tsum([30,30,30], cords))
[90]
You can also pass the sum in as a list of (frequency, number) tuples,
for example:
>>> sums = tsum([(1,116),(1,118),(1,2436),(1,4440)], cords)
>>> list(sorted(sums))
[90, 180]
>>> list(tsum([(3,30)], cords))
[90]
Note that the Possibilities data structure can be reused across multiple
sequential calls to tsum, but it is not thread-safe.