Skip to content

vigetlabs/unscramble

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unscramble

We're gonna write a program that can unscramble a word. Inspired by the "Jumble" puzzle in the newspaper, the program should accept a single, scrambled word and return a matching entry from the English dictionary.

> ./unscramble cofer
force
> ./unscramble sasewe
seesaw

Basic guidelines:

  1. A scrambled or jumbled word has only one valid answer.
  2. Use the contents of /usr/share/dict/words as a dictionary.

Bonus points:

  1. Make it fast (try testing longer words, for example).
  2. Complete the exercise using a programming language that is new to you.

To start:

  1. Clone this repository.
  2. Create a directory based on the name of your implementation language (e.g. languages/C)
  3. Create a simple Rakefile that has, at a minimum, a build task within your language's namespace (e.g. C:build). You should check the environment and fail fast if dependencies aren't met.
  4. Create your implementation.
  5. From the project root run rake run[<language>] to test your language (e.g. rake run[bash]; zsh users will have to quote the argument, e.g. rake run'[bash]'), or rake to test all languages.

Note that the tests run against English words. If you use a different language, symlink /usr/share/dict/words to an English word list to run the tests. If your system does not come with an English word list installed, install wamerican or wbritish (e.g. Ubuntu apt-get install wamerican); english-words's words.txt will do as well.

Example Rakefile

namespace :C do
  task :check do
    `which cc`
    raise "Please ensure that you have a valid C compiler" unless $?.success?
  end

  task :build => :check do
    path = File.dirname(__FILE__)
    `cd #{path}; make unscramble`
  end
end