u/Mysterious-Insect858

Image 1 — Collatz simulator using balanced ternary strings and rewrite rules (No arithmetic)
Image 2 — Collatz simulator using balanced ternary strings and rewrite rules (No arithmetic)
Image 3 — Collatz simulator using balanced ternary strings and rewrite rules (No arithmetic)
▲ 25 r/cellular_automata+1 crossposts

Collatz simulator using balanced ternary strings and rewrite rules (No arithmetic)

Hey,

Just wanted to share a little project. Not claiming any crazy math proof here, just a representation of Collatz using **balanced ternary** (`+`, `o`, `-`) instead of normal binary or base-10.

Because of how balanced ternary works, you can basically bypass normal CPU math and run the operations as simple text replacement rules on a string.

How it works:

  • Parity: If the count of non-zero trits (`+` or `-`) is even, the number is even.
  • 3x+1: Just append a `+` to the end of the little-endian string. O(1) time, no real math needed.
  • Divide by 2: The string splits from left to right into blocks bounded by non-zero trits. Then it just uses two basic substitution rules:
  1. Same signs: a(0...n)a` ➔ `aa'... (n+1) times` (e.g., `+000+` becomes `+----`)
  2. Opposite signs: a(0...n)a'` ➔ `0a... (n+1) times` (e.g., `+000-` becomes `0++++`)

Piped the output through `sed` to colorize the trits (`o` = green, `+` = white, `-` = red) so it generates a neat cellular automaton history grid in the terminal as it collapses down to 1.

The photos are seeds of 100, 2^(31) -1, and 27 respectively

Just a cool toy. Let me know what you think or if anyone else has messed with block decomposition for base-3 halving.

u/Mysterious-Insect858 — 9 days ago