Given a binary string of length 8. Make the string circular.
Count number of places where adjacent bits are different. Print “Uniform” if this count \le 2
Since this problem was a cakewalk, it is quite straightforward to code.
There is quite less to explain apart from giving some observations.
for(int i=0;i<8;++i) count += s* != s[(i+1)&7];
for i in range(8): count += s* != s[i-1]
To have count=0 the string must have 8\space 0's or 8\space 1's.
It is not possible to have count=1.
To have count = 2, the string must have exactly one 1 or exactly one 0.
So for this problem the total number of 1 in the string can be 0, 1, 7, 8.