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:
- A scrambled or jumbled word has only one valid answer.
- Use the contents of
/usr/share/dict/wordsas a dictionary.
Bonus points:
- Make it fast (try testing longer words, for example).
- Complete the exercise using a programming language that is new to you.
To start:
- Clone this repository.
- Create a directory based on the name of your implementation language (e.g.
languages/C) - Create a simple
Rakefilethat has, at a minimum, abuildtask within your language's namespace (e.g.C:build). You should check the environment and fail fast if dependencies aren't met. - Create your implementation.
- 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]'), orraketo 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
Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
