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 5 4 2
0 1 2 2 1 2 2 4 5 6 6 6 6 6 4 4 1 1 2 1 2 1 1 0
Code: Select all
.##########....
.##########....
....######.....
......####.....
.......####..##
.......########
#####..########
###############
..#########..##
....######.....
...............
...............
...............
...............
...............
...............
...............
...............
...............
...............
...#########...
..###########..
.....#####.....
......####.....
.......#......#
.......#......#
##.....#.....##
##############.
..#########....
....######.....
...............
...............
...............
......#####....
.....#....##...
....#......##..
.#############.
.#############.
..##......##...
...............
...............
.#############.
.#...........#.
.#.#########.#.
.#.#.......#.#.
.#.#.......#.#.
.#.#########.#.
.#...........#.
.#############.
...............
.#...#.....#...
.######...###..
.######..####..
...###...####..
...###..######.
..#############
..#####..######
.#####.....###.
.#.###.........
....#..........
...............
...............
...............
...............
...............
...............
...............
...............
...............
...............
Code: Select all
set all cells to unknown
do {
for every scan line {
count the number of unknown, blank, and filled cells
if the count of filled cells equals the number of filled cells, then change unknown cells to blank
if the count of unknown cells plus the count of filled cells equals the number of filled cells, then change unknown cells to filled
}
} while(a cell was modified)
If any cells are unknown or any scan line's count of filled cells doesn't equal the number of filled cells, then print a blank grid, otherwise print the completed grid.