Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kata/8-kyu/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
- [Invert values](invert-values "5899dc03bc95b1bf1b0000ad")
- [Is he gonna survive?](is-he-gonna-survive "59ca8246d751df55cc00014c")
- [Is it a number?](is-it-a-number "57126304cdbf63c6770012bd")
- [Is it a palindrome?](is-it-a-palindrome "57a1fd2ce298a731b20006a4")
- [Is it even?](is-it-even "555a67db74814aa4ee0001b5")
- [Is n divisible by x and y?](is-n-divisible-by-x-and-y "5545f109004975ea66000086")
- [Is the string uppercase?](is-the-string-uppercase "56cd44e1aa4ac7879200010b")
Expand Down
5 changes: 5 additions & 0 deletions kata/8-kyu/is-it-a-palindrome/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# [Is it a palindrome?](https://www.codewars.com/kata/is-it-a-palindrome "https://www.codewars.com/kata/57a1fd2ce298a731b20006a4")

Write a function that checks if a given string (case-insensitive) is a [palindrome](https://en.wikipedia.org/wiki/Palindrome).

A palindrome is a word, number, phrase, or other sequence of symbols that reads the same backwards as forwards, such as `madam` or `racecar`.
5 changes: 5 additions & 0 deletions kata/8-kyu/is-it-a-palindrome/main/Palindrome.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface Palindrome {
static boolean isPalindrome(String x) {
return new StringBuilder(x).reverse().toString().equalsIgnoreCase(x);
}
}
19 changes: 19 additions & 0 deletions kata/8-kyu/is-it-a-palindrome/test/SampleTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class SampleTests {
@ParameterizedTest
@ValueSource(strings = {"a", "aba", "Abba", "Bob", "Madam", "AbBa", ""})
void sample(String str) {
assertTrue(Palindrome.isPalindrome(str));
}

@ParameterizedTest
@ValueSource(strings = {"hello", "123521"})
void negative(String str) {
assertFalse(Palindrome.isPalindrome(str));
}
}