Emmanuel Valverde Ramos
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 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`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully