Cross Flip
InterviewTime limit1sMemory limit256 MB
Find the fewest cross-shaped clicks that turn an all-white 3x3 board into each given target pattern.
- Level
Easy3 of 10
- Topics
- Brute force, Simulation
- Solved
- No attempts yet
Problem
You are given a 3x3 board. Each square starts out white or black. When you click a square, that square and the squares next to it to the north, south, east, and west (the ones that exist on the board) flip color: white becomes black, and black becomes white.
You want to turn an all-white 3x3 board into the board given in the input. You cannot rotate the board.
Input
The first line has the number of test cases ().
Each test case is three lines of three characters. * means black and . means white.
Output
For each test case, print the minimum number of clicks needed to turn the all-white board into the board given in the input, one answer per line.