How to Create a Word Unscrambling Program?

  • Thread starter Thread starter Hybr!d
  • Start date Start date
  • Tags Tags
    Program
Click For Summary
SUMMARY

The discussion focuses on creating a word unscrambling program using C programming language. Participants suggest methods for efficiently matching jumbled words with a predefined word list. The initial approach involves sorting letters of the jumbled word and comparing them with a sorted list of words. An alternative optimization technique proposed includes counting letter occurrences and calculating ordinal sums to reduce search complexity from O(N) to O(log N).

PREREQUISITES
  • Basic knowledge of C programming
  • Understanding of sorting algorithms
  • Familiarity with data structures, specifically arrays
  • Concept of time complexity in algorithms
NEXT STEPS
  • Implement sorting algorithms in C, such as quicksort or mergesort
  • Explore data structures for efficient searching, like hash tables
  • Learn about time complexity analysis to optimize algorithms
  • Research advanced string manipulation techniques in C
USEFUL FOR

Programmers, computer science students, and software developers interested in algorithm optimization and string processing techniques.

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 someone 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
 
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 43 ·
2
Replies
43
Views
6K
  • · Replies 22 ·
Replies
22
Views
2K
Replies
69
Views
10K
Replies
33
Views
3K
Replies
37
Views
5K
Replies
8
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 8 ·
Replies
8
Views
1K
  • · Replies 8 ·
Replies
8
Views
2K