How to Create a Word Unscrambling Program?

  • Thread starter Thread starter Hybr!d
  • Start date Start date
  • Tags Tags
    Program
AI Thread Summary
The discussion focuses on creating an application to unscramble jumbled words using a predefined word list. A basic algorithm is proposed, which involves taking a scrambled input, converting it to lowercase, sorting the letters, and then comparing it against a sorted list of characters derived from known words. Suggestions for optimization include counting the letters and calculating their ordinal values to improve search efficiency. This approach could potentially reduce the search complexity significantly. Participants emphasize the importance of pre-computing data to enhance performance, while also cautioning against excessive memory usage. Overall, the conversation highlights various strategies for developing an effective word unscrambling application.
Hybr!d
Messages
18
Reaction score
0
Hello Guys.

I was wondering how would you go around making an application that unjumbles words. It uses a wordlist and extracts the unjumbled word like.

jumbled: ial
unjumbled:ali

I hope somone got an idea. Thanx
 
Technology news on Phys.org
Here is a start in C:

word list:
Code:
char wordlist[4][8]={"all", "some", "small", "sine"};
char alpha[4][10]={0x0};


wordlist has four elements: each word we know how to unscramble
alpha is an alphabetically arranged set of characters from wordlist:
wordlist alpha
all all
some emos
small allms
sine eins

The algorithm is:
Code:
input a scrambled word
lowercase all the letters in the word
alphabetize the letters in the scrambled (just like we did for "alpha" above)
search thru each element of alpha to find an exact match
print the corresponding element in wordlist -
  i.e., if you find an exact match with "emos" print "some"
  else printf "not found in list"
 
mcnamara's onto a good start, but don't try to store all those words in memory!

First, sort the letters in the target word. Read the words from the word list (a text file) one at a time, sort the characters, and compare with the sorted target word.

- Warren
 
An even faster way would be to count the letters in the word and add up the ordinal of all the letters (1=a, 2=b, etc.). Then match the number of letters and total ordinal sum against your word list (where you've already computed these two numbers for each word, and sorted numerically), and then try permutations of your test word against the matched words from your word list. Should take the search from order(N) down to order(log[N]) or less, I would think...
 
berkeman,

There are a ton of different ways one could optimize this for run-time performance, particularly by storing pre-computations like the one you described.

- Warren
 
Thanx guys. I got a start
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top