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.)
- A. 5
- B. 4
- C. 3
- 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
- Problem: How many integers x with 1 ≤ x ≤ 100 have an odd number of set bits in their binary representation AND are odd themselves?
- Problem: What is the minimum number of bit flips needed to convert 29 into 15 (flips of single bits in binary)?
- Problem: What is the largest power of 2 that divides 480 × 36?
- Problem: How many pairs (a, b) with 1 ≤ a < b ≤ 20 satisfy gcd(a, b) = 1?
- Problem: Find the last digit (units digit) of 7^(7^7) in decimal.
- Problem: How many subsets of {3, 5, 7, 11, 13, 17} have a sum equal to 24 (the empty set is excluded since its sum is 0)?