Anagram Solver – extracted from one of my interviews

Hi folks

For whom who is going to undertake RoR/Ruby or general software development position, your employer might give you some sort of short test for Round 1. Anagram is probably one of the good question that they might ask. Because it is a simple test yet involves many techniques that a code reviewer could testify your competence in programming. Here is one of the test question from a Ruby job interview that I had:

Given a file containing one word per line, print out all the combinations of words that are anagrams; each line in the output should contain a set of input words that are anagrams of each other. No word should appear in the output more than once

For added programming pleasure, find the longest words that are anagrams, and the set of anagrams containing the most words.

From the employer perspective, they will pay attention in how you approach this problem and the methodology how you test it too. There are many ways to tackle this question, however I guess the best way is to use Hash due to its n log(n) algorithm is more efficient than other methods. Additionally, an unit test with RSpec would be a plus. Please check my code at:

About Jones Lee

Nothing much about me..

One response to “Anagram Solver – extracted from one of my interviews

  1. Pingback: Anagram Solver extracted from one of my interviews The | ALL Best News

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: