Back to writeups
HTBcodinghardsolved

Chaogen

2 Jul 2026 · by 0xIDA

Solvers

Chaogen

Author: 0xIDA
Platform: HTB · Category: coding · Difficulty: hard

Solvers

Summary

A multi-quadrant cellular automaton challenge. A square N×N petri dish (N multiple of 4) is divided into 4 equal quadrants, each governed by one of four unknown rule-sets in B/S/M/V format. Given the initial grid, the 4 rule definitions, and a snapshot at generation 3, we must deduce the quadrant→rule mapping by brute-forcing all 4! = 24 permutations, then simulate to generation T.

Solution

Step 1: Understand the rules

Each rule string is in Bx/Sy/Mz/Vw format:

  • B = birth: dead cell (0) becomes alive (1) if neighbor count ∈ B
  • S = survival: alive cell (1) stays alive if neighbor count ∈ S
  • M = mutate: alive cell (1) becomes mutated (2) if neighbor count ∈ M
  • V = virus: mutated cell (2) with neighbor count ∈ V decreases its top/bottom neighbors by 1

Additional mechanics:

  • Moore neighborhood (8 cells), toroidal wrapping
  • Any non-zero (1 or 2) counts as alive for neighbor counting
  • M before S: for alive cells, mutation is checked before survival
  • Virus triggers on pre-update mutated cells using pre-update neighbor counts
  • Mutated cell (2) stays mutated if neighbor count ∈ M or ∈ S, otherwise dies (0)
  • Virus applies after all cells update; no chaining within a generation

Step 2: Key discovery — correct simulation order

Testing against the example revealed the correct interpretation of ambiguous rule priorities:

InterpretationTest Result
M before S, virus uses pre-update cell✅ Matches example
M before S, virus uses post-update cell❌ 4/64 mismatches
S before M, virus uses pre-update cell❌ 2/64 mismatches
S before M, virus uses post-update cell❌ 2/64 mismatches

Step 3: Brute-force the mapping

For each of the 24 permutations of rules→quadrants:

  1. Simulate from generation 0 → 3
  2. Compare with the provided gen-3 snapshot
  3. When a match is found, continue simulation to generation T

Step 4: Submit and get the flag

Submitted the Python solution to the coding platform's /run endpoint. All hidden test cases pass, returning the flag.

Flag

HTB{ph4s3s0fL1f3_r3v3rs3m3_09}

Key takeaways

  • Rule priority matters: in cellular automata with mutation, the order of checking survival vs mutation fundamentally changes the outcome
  • Virus effect semantics: whether the trigger condition reads pre- or post-update cell state is critical
  • Brute-forcing a small permutation space (24 mappings) is sufficient when you have a known reference state at generation 3