Word Scramble

Word Scramble


As I mentioned in "#29 Sudoku Solver" on Sudoku Solver, word scramble is a classic game. There is something fascinating about a game that can hold your attention while exercising your vocabulary. This classic game can be found in newspapers, magazines, and even books dedicated solely to word scrambles. But who needs those when you can customize your own game?

The Code

 unless ARGV[0] and File.exists?(ARGV[0])
     puts "\n\nUsage is wordScramble.rb <word.file>\n\n"

 tries = 10

 words = File.readlines(ARGV[0])
 mystery_word = words[rand(words.size)].chomp

 scramble_word = mystery_word.split(//).sort_by{rand}.join ...

Get Wicked Cool Ruby Scripts now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.