Data Structures & AlgorithmsHardICPC regional · Product Company SDE

Problem: A Rule 90 cellular automaton on an infinite line starts with a single live cell. A cell's next state is 1 exactly when its two neighbours differ (left XOR right). After 3 generations, how many live cells are there?

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

Correct answer: B. 4

Each generation sets a cell to the XOR of its two neighbours, which produces a Sierpiński-like pattern. Including the cell's own state in the XOR gives Rule 150 and a different count.

More Coding Interview Problems questions

Exams that ask this topic