Company: phonepe_30july
Difficulty: medium
Song of Ice and Water Problem Description Picture a row of 8 enchanted cells that can each hold either ice (1) or water (0). Every day, an enchantment updates every cell at once according to this rule: If a cell's two neighbors are in the same state as each other (both ice or both water), the cell turns to ice the next day. Otherwise, the cell turns to water the next day. The leftmost and rightmost cells only have a single neighbor each, so they always turn to water the next day no matter what. Given the row's starting state and a count n, report the row's state after n days have passed. Input Format First line: 8 space-separated integers (0 or 1), the row's starting state. Second line: an integer n, the number of days to simulate. Output Format One line with 8 space-separated integers (0 or 1), the row's state after n days. Constraints 1 <= n <= 10^9 Examples Example 1: Input: 0 1 0 1 1 0 0 1 1 Output: 0 1 1 0 0 0 0 0 Explanation: Cell 0 and Cell 7 always turn to 0 (water) the n