---
# System prepended metadata

title: Palindrome Kata

---

# Palindrome Kata

## Description

The exercise for today is a small kata designed to help you practice the Test-Driven Development (TDD) cycle and become more comfortable with the programming language of your choice. Your task is to determine whether an input is a palindrome or not. This is a simple yet effective exercise to reinforce testing and iterative development.

### What is a Palindrome?

A palindrome is a word, phrase, number, or sequence of characters that reads the same backward as forward (ignoring spaces, punctuation, and capitalization).

Your task is to write a function that takes a string or a number as input and returns `true` if the input is a palindrome and `false` otherwise.

## Requirements

1. **Input Types**:

   - The function should handle both strings and numbers.
   - It should ignore spaces, punctuation, and differences in letter case.

2. **Output**:

   - Return `true` if the input is a palindrome, `false` otherwise.

3. **Considerations**:

   - Strings can contain uppercase and lowercase letters, spaces, punctuation, and special characters.
   - Numbers can be treated as strings when checking if they are palindromes.

## Test Cases

Below is a set of test cases that you should implement and make sure they pass before you continue. These examples will help you understand different scenarios where an input might or might not be a palindrome.

### Simple Test Cases:

1. "anna"   ⇒ `true`
2. "walter" ⇒ `false`
3. `12321`    ⇒ `true`
4. `123456`   ⇒ `false`
5. "aba"    ⇒ `true`
6. "abc"    ⇒ `false`

### Cases with Mixed Characters:

1. "A man a plan a canal Panama" ⇒ `true`
2. "Was it a car or a cat I saw?" ⇒ `true`
3. "No lemon, no melon" ⇒ `true`
4. "Hello, World!" ⇒ `false`

### Cases with Punctuation and Spaces:

1. "Madam, in Eden, I'm Adam" ⇒ `true`
2. "Eva, can I see bees in a cave?" ⇒ `true`
3. "Palindrome? Not really!" ⇒ `false`

### Cases with Numbers and Letters:

1. "a1b2b1a" ⇒ `true`
2. "1a2b3b2a1" ⇒ `true`
3. "abc123321cba" ⇒ `true`
4. "123abcba321" ⇒ `false`

### Special Characters and Upper/Lower Case Sensitivity:

1. "abcdDCBA" ⇒ `true`
2. "ABBA" ⇒ `true`
3. "aBBa" ⇒ `true`
4. "aBba!" ⇒ `false`

### Cases with Special Characters Ignored:

Assuming we are ignoring spaces, punctuation, and case.

1. "Able was I, I saw Elba" ⇒ `true`
2. "Racecar!" ⇒ `true`
3. "Step on no pets!" ⇒ `true`

### Long Strings:

1. "abcdefghhgfedcba" ⇒ `true`
2. "abcdefghijk" ⇒ `false`
3. "aaabbbcccbbbaaa" ⇒ `true`

### Edge Cases:

1. `12344321` ⇒ `true`
2. "abcba " ⇒ `false` (spaces at the end should be handled)
3. "0" ⇒ `true`

## Challenge Yourself

Once you have implemented the solution and all tests are passing, try to refactor the solution:

1. Try a new approach to solve the problem and use the existing tests to verify correctness.
2. Modify the implementation in a way that impacts different parts of the code and see how you can ensure all tests still pass.
3. Find a good abstraction that supports different kinds of inputs by using **triangulation** (repeating or generalizing the implementation up to three times).
4. If you already know how to do TDD, try applying **Test && Commit || Revert**.

This exercise is intended to help you reinforce the practice of **Test-Driven Development (TDD)** while exploring various approaches to solve a classic problem. The goal is to practice writing tests before code, evolving the solution incrementally, and ensuring that tests provide strong support for making changes. Remember to keep the spirit of experimentation and learning alive—working in small steps is key to building confidence and creating a robust solution.

## Advanced Level

After completing the basic kata, take it to the next level by adding multi-language support. Allow the program to accept an additional parameter specifying the language. Based on the provided language, adapt the palindrome check to account for language-specific special characters. This adds an extra layer of complexity and encourages a more flexible and internationalized solution.

### Examples for the Second Level:

1. "¿Acaso hubo búhos acá?" (Spanish) ⇒ `true`
2. "¡A mamá Roma le aviva el amor a mamá!" (Spanish) ⇒ `true`
3. "Sir, I demand, I am a maid named Iris" (English) ⇒ `true`
4. "No 'x' in Nixon" (English) ⇒ `true`
5. "Is this a palindrome?" (English) ⇒ `false`

## Second Level Challenge

For the second level of the kata, you are encouraged to extend your program by implementing multi-language support. This involves allowing the user to specify a language, and based on that language, adjusting the palindrome check to appropriately handle language-specific characters and symbols. This is meant to simulate real-world scenarios where software must adapt to various international requirements and support diverse user bases. By doing this, you will be practicing creating adaptable and culturally aware software, an important skill in today’s globalized world.

### Additional Examples for the Second Level (Language-Specific Special Characters):

#### Spanish:
1. "¿Será acaso acaso será?" ⇒ `true`
2. "¡Ojo, no te pases!" ⇒ `false`

#### English:
1. "What's up? Pup saw?" ⇒ `true`
2. "Hello there!" ⇒ `false`

