Ruby interview questions

Want to become an expert in cracking Ruby interview questions?

Start with practicing the questions below. Whether a question involves multiple choice or live coding, we will give you hints as you go and tell you if your answers are correct or incorrect.

After that, take our timed public Ruby interview questions test.

To use our service for testing developers, purchase one of the paid plans for companies.


1. Palindrome
Ruby Strings Public

A palindrome is a word that reads the same backward or forward.

Write a function that checks if a given word is a palindrome. Character case should be ignored.

For example, is_palindrome("Deleveled") should return true as character case should be ignored, resulting in "deleveled", which is a palindrome since it reads the same backward and forward.

Easy  
10min
Solve question

2. File Owners
Ruby Language Public

Implement a group_by_owners function that:

  • Accepts a hash containing the file owner name for each file name.
  • Returns a hash containing an array of file names for each owner name, in any order.

For example, for hash {'Input.txt' => 'Randy', 'Code.py' => 'Stan', 'Output.txt' => 'Randy'} the group_by_owners function should return {'Randy' => ['Input.txt', 'Output.txt'], 'Stan' => ['Code.py']}.

Easy  
15min
Solve question

3. Path
Ruby Data structures Strings Public

Write a function that provides change directory (cd) function for an abstract file system.

Notes:

  • Root path is '/'.
  • Path separator is '/'.
  • Parent directory is addressable as '..'.
  • Directory names consist only of English alphabet letters (A-Z and a-z).
  • The function should support both relative and absolute paths.
  • The function will not be passed any invalid paths.
  • Do not use built-in path-related functions.

For example:

path = Path.new('/a/b/c/d')
path.cd('../x')
puts path.current_path

should display '/a/b/c/x'.

Hard  
30min
Solve question

If you feel ready, take one of our timed public Ruby interview questions tests:
  • HTML/CSS, JavaScript, Ruby, and SQL online test ( Easy  /  Hard )
  • Ruby online test ( Easy  /  Hard )
  • Ruby and SQL online test ( Easy  /  Hard )
  • Ruby on Rails online test ( Easy )
Not exactly what you are looking for? Go to our For developers section.