Cat and Mouse – Easy Version

From by Edxael  (that’s me)


You will be given a string (x) featuring a cat ‘C’ and a mouse ‘m’. The rest of the string will be made up of ‘.’.

You need to find out if the cat can catch the mouse from it’s current position. The cat can jump three characters. So:

C…..m returns ‘Escaped!’ <– more than three characters between

C…m returns ‘Caught!’ <– as there are three characters between the two, the cat can jump.

Note:  The following code is not written by me, it was created by another user of it belongs to the user: “carlyminjoy



Copyright 2017. All rights reserved.

Posted January 9, 2017 by Edmundo in category "Ruby Examples