Skip to content

Commit 3893d16

Browse files
* docs: kata description * feat: kata/cat-and-mouse-easy-version --------- Co-authored-by: ParanoidUser <5120290+ParanoidUser@users.noreply.github.com>
1 parent aefa582 commit 3893d16

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# [Cat and Mouse - Easy Version](https://www.codewars.com/kata/cat-and-mouse-easy-version "https://www.codewars.com/kata/57ee24e17b45eff6d6000164")
2+
3+
You will be given a string featuring a cat `'C'` and a mouse `'m'`. The rest of the string will be made up of `'.'`. The string will start
4+
with the cat, and end with the mouse.
5+
6+
You need to find out if the cat can catch the mouse from its current position. The cat can jump over at most three characters. So:
7+
8+
`"C.....m"` returns `"Escaped!"` <-- more than three characters between
9+
10+
`"C...m"` returns `"Caught!"` <-- as there are three characters between the two, the cat can jump.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface Kata{
2+
static String catMouse(String x){
3+
return x.length() > 5 ? "Escaped!" : "Caught!";
4+
}
5+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import static org.junit.jupiter.api.Assertions.assertEquals;
2+
3+
import org.junit.jupiter.params.ParameterizedTest;
4+
import org.junit.jupiter.params.provider.CsvSource;
5+
6+
class CatMouseTest {
7+
@ParameterizedTest
8+
@CsvSource(textBlock = """
9+
C....m, Escaped!
10+
C..m, Caught!
11+
C.....m, Escaped!
12+
C.m, Caught!
13+
C...m, Caught!
14+
Cm, Caught!
15+
""")
16+
void sample(String s, String expected) {
17+
assertEquals(expected, Kata.catMouse(s));
18+
}
19+
}

kata/7-kyu/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
- [Calculate the Harmonic Conjugated Point of a Triplet of Aligned Points](calculate-the-harmonic-conjugated-point-of-a-triplet-of-aligned-points "5600e00e42bcb7b9dc00014e")
7474
- [Cartesian coordinates from degree angle](cartesian-coordinates-from-degree-angle "555f43d8140a6df1dd00012b")
7575
- [Cartesian neighbors](cartesian-neighbors "58989a079c70093f3e00008d")
76+
- [Cat and Mouse - Easy Version](cat-and-mouse-easy-version "57ee24e17b45eff6d6000164")
7677
- [Cat Years, Dog Years (2)](cat-years-dog-years-2 "5a6d3bd238f80014a2000187")
7778
- [Cats and shelves](cats-and-shelves "62c93765cef6f10030dfa92b")
7879
- [Center of the Matrix](center-of-the-matrix "54c91b5228ec4c3b5900036e")

0 commit comments

Comments
 (0)