diff --git a/katas/make-palindrome/make-palindrom.js b/katas/make-palindrome/make-palindrom.js new file mode 100644 index 0000000..90d2ff9 --- /dev/null +++ b/katas/make-palindrome/make-palindrom.js @@ -0,0 +1,3 @@ +function makePalindrome(text){ + // ... +} diff --git a/katas/make-palindrome/make-palindrom_test.js b/katas/make-palindrome/make-palindrom_test.js new file mode 100644 index 0000000..988d706 --- /dev/null +++ b/katas/make-palindrome/make-palindrom_test.js @@ -0,0 +1,16 @@ +describe('makePalindrome function', function() { + + it('should return existing palindromes without modification', function() { + expect(makePalindrome('a')).toBe('a'); + expect(makePalindrome('radar')).toBe('radar'); + expect(makePalindrome('racecar')).toBe('racecar'); + }); + + it('expand strings to form palindromes', function() { + expect(makePalindrome('ab')).toBe('aba'); + expect(makePalindrome('abb')).toBe('abba'); + expect(makePalindrome('abc')).toBe('abcba'); + expect(makePalindrome('rad')).toBe('radar'); + expect(makePalindrome('race')).toBe('racecar'); + }); +}); diff --git a/katas/make-palindrome/readme.md b/katas/make-palindrome/readme.md new file mode 100644 index 0000000..611e77b --- /dev/null +++ b/katas/make-palindrome/readme.md @@ -0,0 +1,22 @@ +####Description: + +Write a function makePalindrome that takes a string as the argument and then returns the shortest possible palindrome made from that string without modifying the original string. +If more than one palindrome can be made, the function should return the solution where the given string appears at the beginning of the palindrome. + +Only single word strings will be passed as arguments to the function. + +####Example: + +```js +makePalindrome('a') --> 'a' +makePalindrome('ab') --> 'aba' +makePalindrome('abc') --> 'abcba' +makePalindrome('race') --> 'racecar' +makePalindrome('leveled') --> 'deleveled' +``` + +See [tests in make-palindrom_test.js](https://github.com/AlexVvx/code-wars/blob/master/katas/make-palindrom/make-palindrom_test.js) + +#####[Original Kata](https://www.codewars.com/kata/make-a-palindrome) + +Good luck