PROBLEM LINK:
Author: Praveen Dhinwa
Tester: Jingbo Shang
Editorialist: Vaibhav Tulsyan
PROBLEM
Given a string S of length 8, check if number of positions i such that S_i \ne S_{(i + 1) \% 8} is at most 2 or not.
EXPLANATION
This problem is inspired by local binary patterns in machine learning for edge detection in an image.
You have to count the number of transitions in a rotated array of length 8. This can be done by just iterating over the array. The implementation is provided below.
transitions = 0
for i in range(8):
if (s[i] != s[(i + 1) % 8]):
transitions += 1
AUTHOR’S AND TESTER’S SOLUTIONS:
To be uploaded soon.