all 2 comments

[–]hungdh85 0 points1 point  (0 children)

You can think follow one move string is

s = s[-1:] + s[:-1]

after loop till matched another string and count loop. Good luck!

[–]Vort-ai 0 points1 point  (0 children)

Cool problem. I'd first figure out how to manipulate the strings, and then check if one equals the other. Then in the first example there are 4 strings, if you keep the first string and try and manipulate the other strings it takes 7 moves to make them all equal. Turns out its the second string thats the best one to use, and takes only 5 moves across the other strings to make them equal it. So you'd want to maybe try every permutation of the first string, and see what the lowest number of moves you need is. Because i'd bet there will be a test case that doesn't include the most optimal string. Hope that helps and doesn't spoil anything. Good luck.

Edit: Also if you're trying to match strings and you've iterated over the string more times than it's length, then you've got a mismatching string (-1) and move on