Description
Write a program that inputs two strings continuously and:
● outputs each input string on a separate line.
● determines whether first one is a rotation of the other and outputs “true” or “false” relatively.
● says “bye.” and exits if the first string is “exit”.
Given two strings s1 and s2, whether s2 is a rotation of s1 is defined as follows:
If we cut s1 at an index k into two substrings as s1a and s1b, then we must be able to get s2 by s1b + s1a.
Rotation examples:
“cdeab” is a rotation of “abcde”
“bcdea” is a rotation of “abcde”
“bcdae” is a not rotation of “abcde”
Hint: If the concatenation of s1 with itself contains s2 then s2 is a rotation of s1.
Example run:
Reviews
There are no reviews yet.