Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Word Jumble Algorithm

Given a word jumble (i.e. ofbaor), what would be an approach to unscramble the letters to create a real word (i.e. foobar)? I could see this having a couple of approaches, and I think I know how I'd do it in .NET, but I curious to see what some other solutions look like (always happy to see if my solution is optimal or not).

This isn't homework or anything like that, I just saw a word jumble in the local comics section of the paper (yes, good ol' fashioned newsprint), and the engineer in me started thinking.

edit: please post some pseudo code or real code if you can; it's always nice to try and expand language knowledge by seeing examples like this.

like image 772
CodeMonkey1313 Avatar asked Apr 27 '10 14:04

CodeMonkey1313


People also ask

How do you solve the jumbled word trick?

Tip 1: Look for prefixes or suffixes such as “RE” or “ING”. These can help you extend other words. Tip 2: Try to find letters that often go together in words like “BR” or “TH”. Tip 3: Move the vowels and consonants apart.

How do you arrange jumble words in Python?

This is a two players game, firstly program pick a random word from the given list of words using choice() method of random module. After shuffling the characters of picked word using sample method of random module and shows the jumbled word on the screen.

Who creates the jumble puzzle?

Jumble was created in 1954 by Martin Naydel, who is better known for his work on comic books. Daily and Sunday Jumble puzzles appear in over 600 newspapers in the United States and internationally. As of 2014, Jumble is created by David L. Hoyt and Jeff Knurek.


1 Answers

Have a dictionary that's keyed by the letters of each word in sorted order. Then take you jumble an sort the letters - look up all the words in the dictionary by that sorted-letter string.

So, as an example, the words 'bear' and 'bare' would be in the dictionary as follows:

key    word
-----  ------
aber    bear
aber    bare

And if you're given the jumble, 'earb', you'd sort the letters to 'aber' and be able to look up both possible words in the dictionary.

like image 86
Michael Burr Avatar answered Sep 27 '22 19:09

Michael Burr