Recognize the flag challenge | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Recognize the flag challenge

Mary is developing a system for flag recognition. A flag consist of 6x9 matrix of chars, Each char represents one color. System is in it's very early phase so Mary is only recognizing basic flags: A) first 2 rows one color, second 2 rows second color, final 2 rows another color (or same as first 2 rows) B) first 3 columns one color, second 3 columns another color, and final 3 columns another color (or same as first 3 columns). As you can see middle stripe (vertical or horizontal) must bee different from other 2 stripes, but those 2 other stripes can be the same. Example A: AAAAAAAAA AAAAAAAAA BBBBBBBBBB BBBBBBBBBB CCCCCCCCC (AAAAAAAAA) CCCCCCCCC (AAAAAAAAA) Example B: AAABBBCCC (AAA) AAABBBCCC (AAA) AAABBBCCC (AAA) AAABBBCCC (AAA) AAABBBCCC (AAA) AAABBBCCC (AAA) Write an algorithm in any lang that will ask user for input of 6x9 matrix of chars. Then it needs to calculate how many single chars must be replaced in order to get that inputted flag to basic one. Example INPUT: CCCCCCCCC CCCCCCCCC CBBBBBBBC PBBBBBBBP PPPPPPPPP PPPPPPPPP //this is obviously case A so algorithm should see that in 3rd and 4rd row two C's and two P's must be replaced with B OUTPUT: 4 Example INPUT: AZZAAAMMA AZZAAAMMA ZZZAMAMMM ZZZAAAMMM AZZAAAMMA AZZAAAMMA OUTPUT: 9 //this is case B If you want to challenge yourselves a bit more give exact coordinates of change, and which letter must be replaced with which one (not that hard, believe me) Motivation: I am very very very bad logical thinker, but first idea that came up was spot on.... Please I beg you don't give up, you can do it, no matter how long it takes, just do it :D

10th Mar 2018, 9:42 AM
Elva
Elva - avatar
3 Answers
+ 4
@Vishal didn't see that, thanks
10th Mar 2018, 10:14 AM
Elva
Elva - avatar
10th Mar 2018, 10:13 AM
Vishal Pal❄️⚛️
Vishal Pal❄️⚛️ - avatar
+ 2
No problem @Elva
10th Mar 2018, 10:22 AM
Vishal Pal❄️⚛️
Vishal Pal❄️⚛️ - avatar