Skip to content

Commit b0ffa9b

Browse files
* docs: kata description * feat(8-kyu): kata/is-it-a-palindrome * Trigger CI --------- Co-authored-by: ParanoidUser <5120290+ParanoidUser@users.noreply.github.com>
1 parent f430b8f commit b0ffa9b

4 files changed

Lines changed: 30 additions & 0 deletions

File tree

kata/8-kyu/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
- [Invert values](invert-values "5899dc03bc95b1bf1b0000ad")
126126
- [Is he gonna survive?](is-he-gonna-survive "59ca8246d751df55cc00014c")
127127
- [Is it a number?](is-it-a-number "57126304cdbf63c6770012bd")
128+
- [Is it a palindrome?](is-it-a-palindrome "57a1fd2ce298a731b20006a4")
128129
- [Is it even?](is-it-even "555a67db74814aa4ee0001b5")
129130
- [Is n divisible by x and y?](is-n-divisible-by-x-and-y "5545f109004975ea66000086")
130131
- [Is the string uppercase?](is-the-string-uppercase "56cd44e1aa4ac7879200010b")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# [Is it a palindrome?](https://www.codewars.com/kata/is-it-a-palindrome "https://www.codewars.com/kata/57a1fd2ce298a731b20006a4")
2+
3+
Write a function that checks if a given string (case-insensitive) is a [palindrome](https://en.wikipedia.org/wiki/Palindrome).
4+
5+
A palindrome is a word, number, phrase, or other sequence of symbols that reads the same backwards as forwards, such as `madam` or `racecar`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface Palindrome {
2+
static boolean isPalindrome(String x) {
3+
return new StringBuilder(x).reverse().toString().equalsIgnoreCase(x);
4+
}
5+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import org.junit.jupiter.params.ParameterizedTest;
2+
import org.junit.jupiter.params.provider.ValueSource;
3+
4+
import static org.junit.jupiter.api.Assertions.assertFalse;
5+
import static org.junit.jupiter.api.Assertions.assertTrue;
6+
7+
class SampleTests {
8+
@ParameterizedTest
9+
@ValueSource(strings = {"a", "aba", "Abba", "Bob", "Madam", "AbBa", ""})
10+
void sample(String str) {
11+
assertTrue(Palindrome.isPalindrome(str));
12+
}
13+
14+
@ParameterizedTest
15+
@ValueSource(strings = {"hello", "123521"})
16+
void negative(String str) {
17+
assertFalse(Palindrome.isPalindrome(str));
18+
}
19+
}

0 commit comments

Comments
 (0)