Tell me more ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Read two strings from stdin.
Output Yes if one string is a rotated version of the other.
Otherwise output No

Testcases

Input

CodeGolf GolfCode

Output

Yes

Input

stackexchange changestackex

Output

Yes

Input

stackexchange changestack

Output

No

Input

Hello World

Output

No
share|improve this question
So (abcdefAB, ABabcdef) is a "YES"? – Eelvex Mar 9 '11 at 12:06
Should it really be a rotation or is a combination fine too? eg. what will Stackexchange Stackchangeex return? – jpjacobs Mar 9 '11 at 12:08
@Eelvex, yes. @jpjacobs, It would return No. The rotation is a shift, like those LED scrolling signs – gnibbler Mar 9 '11 at 12:19
Are the strings always whitespace-free and separated by whitespace? – Joey Mar 9 '11 at 15:20
More specifically, what characters are allowed in those strings? – Joey Mar 9 '11 at 15:48

31 Answers

1 2

K3 / Kona, 28

{:[y _in![;x]'!#x;`Yes;`No]}
share|improve this answer
1 2

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.