Skip to content

Instantly share code, notes, and snippets.

@chris-wood
Created April 21, 2016 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris-wood/f37b1061ed974d76d8ee18e6ce726117 to your computer and use it in GitHub Desktop.
Save chris-wood/f37b1061ed974d76d8ee18e6ce726117 to your computer and use it in GitHub Desktop.
number of unique names (algorithmically)
B = 8 # 8 bytes for the fixed name length
total = 0 # accumulator for the number of names
for b in range(1, B + 1):
# Compute the number of unique partitions for all possible values of k
l = [0] * b
partition_total = 0
for k in range(1, b):
partition_total += num_partitions(l, k)
# Multiply the partition total by the number of possible names of length b
num_unique = 2 ** (8 * b)
total += (partition_total * num_unique)
# Debug
print "For b=%d, partition_total=%d" % (b, partition_total)
print "For b=%d, num_unique=%d" % (b, num_unique)
print "Total: %d" % (total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment