2. Challenge: Check Pallindrome

Now it's time to solve a popular coding interview challenge!

WARNING: You will probably feel frustrated at solving these coding challenges - they can become quite difficult!

Check Palindrome

Given a string, write a method called is_palindrome? to check if it is a palindrome. A palindrome is a word or phrase that is the same read from the front and backwards (for example, "racecar", "eve"). The palindrome does not need to be limited to words in the dictionary (strings like "eyebeye", "bsdfdsb" should be considered palindromes).

Make sure that the method works regardless of capitalization.

EXAMPLE

Your code should run like this:

# Input
is_palindrome?("Racecar")

# Output
true

# Input
is_palindrome?("rAcEcar")

# Output
true

# Input
is_palindrome?("banana")

# Output
false

Getting Started

First, download the zip from https://github.com/namespace-team/ruby-core-challenges/archive/master.zip

Next, unzip the folder and navigate to the is_palindrome directory.

cd is_palindrome

Once you are in the folder in the terminal, run the following command:

bundle install

Next, run the following command:

rspec

This will run some tests to see if your code is working. Since you haven't written any code yet, you will see that all of the tests fail. The output should look something like this:

image.png

Next, open up your text editor and open palindrome.rb located inside is_palindrome/lib.

You should see code like this:

def is_palindrome?(string)
# Write your code here!
end

Implement your solution in this file.

Once you have implemented the solution, go into your terminal and run this command again:

rspec

If your solution is correct, you should see an output like this:

image.png

Good luck!

Lesson list