Zastave
Ante is developing a flag recognition system. After a series of filters and algorithms we get a 6×9 matrix of characters where same character denotes same color. The system is in the initial phase of development, so Ante has set a goal to recognize simple flags like these:
CCCCCCCCC
CCCCCCCCC
BBBBBBBBB
BBBBBBBBB
PPPPPPPPP
PPPPPPPPP
CCCCCCCCC
CCCCCCCCC
BBBBBBBBB
BBBBBBBBB
CCCCCCCCC
CCCCCCCCC
ZZZBBBCCC
ZZZBBBCCC
ZZZBBBCCC
ZZZBBBCCC
ZZZBBBCCC
ZZZBBBCCC
ZZZAAAZZZ
ZZZAAAZZZ
ZZZAAAZZZ
ZZZAAAZZZ
ZZZAAAZZZ
ZZZAAAZZZ
In other words, simple flags that ante is considering consists of three equal stripes horizontally or vertically. The color on the middle stripe must differ from the colors on other two stripes. For each matrix, we define a flag similarity measure as the minimum number of cells that need to be replaced by other characters for the matrix to become a simple flag. Write a program that calculates a flag similarity measure for given matrix.
CCCCCCCCC
CCCCCCCCC
CBBBBBBBC
PBBBBBBBP
PPPPPPPPP
PPPPPPPPP Output
4Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.