Palindrome


Collapse Content

A palindrome is a sentence that reads the same backwards and forwards, when the spaces are removed. For example, "madam im adam". Can you write a program that identifies if a sentence is a palindrome?

Note: The input will not contain any capital letters or punctuation.

Challenge

Create a program that prints true if a sentence is a palindrome and false otherwise.

Please sign in or sign up to submit answers.

Alternatively, you can try out Learneroo before signing up.

Comments

  • a solution:

    my code

  • Can anyone help me with this... my code is returning false all the way down... I'm not seeing where I went wrong:

    String clean = word.replace(" ", "");
    
    cont...
  • Working Ruby boilerplate:
    def palindrome?(string)

    end
    
    t = gets.to_i
    t.times do
        sentence = gets.chomp
        print palindrome?(sentence), "\n"
    end
    
  • Trying this again (having trouble with formatting the code):

    `def palindrome?(string)

    end

    t = gets.to_i
    t.times do
    sentence = gets.chomp
    print palindrome?(sentence), "\n"
    end`

Contact Us
Sign in or email us at [email protected]