Daily Challenge (212 Part Series)
You will be given a string (x) featuring a cat 'C', a dog 'D' 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 its current position. The cat can jump (j) characters.
Also, the cat cannot jump over the dog.
if j = 5:
..C.....m. returns 'Caught!' <-- not more than j characters between
.....C............m...... returns 'Escaped!' <-- as there are more than j characters between the two, the cat can't jump far enough
if j = 10:
...m.........C...D returns 'Caught!' <--Cat can jump far enough and jump is not over dog
...m....D....C....... returns 'Protected!' <-- Cat can jump far enough, but dog is in the way, protecting the mouse
Finally, if all three animals are not present, return 'boring without all three'
Want to propose a challenge idea for a future post? Email email@example.com with your suggestions!