Ruby Coding Interview Question: Creating a Palindrome Method in Ruby

In this coding exercise we’ll walk through how to properly create a palindrome method in Ruby, including a discussion on working with case insensitive comparisons.

Summary

Create a method that checks to see if a word is a palindrome or not.

Exercise File

Code File

Exercise Description

Given a string such as:

"tacocat"

Check to see if the word is a palindrome. A palindrome is a word that is spelled out the same way if you reverse the letters. Also, ensure that the palindrome method is case insensitive.

Example Input/Output

"tacocat" # true
"Tacocat" # true
"baseball" # false

Real World Usage

Creating a palindrome method is a common coding interview question. In this exercise, we’ll also cover how to implement case insensitive equality checks. This process is utilized regularly when building out application search engines.

Solution

Can be found on the solutions branch on github.

Jordan Hudgens

view all post
Leave a comment

Please be polite. We appreciate that.

By Daniele Zedda • 18 February

← PREV POST

By Daniele Zedda • 18 February

NEXT POST → 34
Share on