Data Structures & AlgorithmsVery hardICPC regional · Product Company SDE

Problem: Rule 30 cellular automaton on an infinite line starts with a single live cell. Each generation, a cell's new state is determined by its left neighbour l, itself c and right neighbour r via the pattern 111→0, 110→0, 101→0, 100→1, 011→1, 010→1, 001→1, 000→0. After 4 generations, how many live cells are there? (Simulate on a line wide enough to hold all cells.)

  1. A. 5
  2. B. 4
  3. C. 3
  4. D. 6

Correct answer: B. 4

Apply the rule to every cell simultaneously each generation; the pattern's dependence on both neighbours is what makes the count grow. Updating cells in place, left to right, changes the next generation.

More Coding Interview Problems questions

Exams that ask this topic