Alienware is running a contest to win a trip for 2 to New York. All you have to do is decipher an alien message using clues from this page:

Alienware Declassified

It’s actually a pretty simple substitution cipher, and it took me about 10 minutes to figure it out.

What does this have to do with Ruby? Well, I was able to rewrite a few lines of my word finder from Ruby is my timewaster to search for words where you know the length of the word, a few letters, and their positions, like in a crossword puzzle.

Here’s the revised code:

def get_possible_words(dictionary, required_letters)
    re_required_letters = Regexp.new(required_letters)
    possible_words = []

    File.readlines(dictionary).each { |line|
        possible_words << line if line.strip! =~ re_required_letters
    }
    possible_words

end

def list_possible_words(dictionary, required_letters)
    get_possible_words(dictionary, required_letters).each{ |word| puts word }
end

dictionary = “words“ #  /usr/share/dict/words stripped of proper nouns and punctuation

required_letters = “^.ut..e$“ # default just for an example
required_letters = ARGV[0] unless ARGV.length == 0

list_possible_words(dictionary, required_letters)

For example, I needed a 6-letter word that matched the pattern “^.ut..e$”. Running the code against it brought back the following words:

  • butane
  • butene
  • cuttle
  • futile
  • future
  • guttae
  • guttle
  • mutase
  • mutate
  • mutine
  • mutule
  • nutate
  • outage
  • outate
  • outbye
  • outlie
  • outsee
  • outvie
  • puttee
  • rutile
  • suttee
  • suture

Maybe 3 or 4 of those could reasonably be used in a sentence related to aliens that would be readable by someone without an English degree. The more symbols you figure out, the easier it gets, because you can refine your regular expression and figure out which letters it couldn’t be.

The first page of clues (dated July 8, 1947) gives you enough to figure out all but two letters. If you know Alienware’s naming conventions, one of the two letters should be simple to guess. The second page of clues doesn’t give you any letters you couldn’t have guessed from the first, but it eliminates 3 of the possible letters that could be the last symbol. They’re also the least-frequently used letters of the alphabet, so it’s just a guessing game. I took a shot with the one I thought was most likely.

Hint: Look for the numbers first, and think about why Alienware would use them. That’ll get you the most frequently used letters, and it should only get easier from there.

Second hint: Hey Alienware, I have a fondness for review hardware.

In the first of what will hopefully be many attempts to pimp my other site, Too Many Secrets, I’ve decided to have a little contest.

Whoever writes the secret that gets voted up the most between now and December 1st will win a $10 Amazon Gift Certificate.

Post a secret (it’s anonymous), and tell your friends to vote for you or add secrets of their own. Isn’t a little shame worth it for $10?

The link again, if you somehow missed it: Too Many Secrets