This solution will not find words which are made of multiple letters, from the same number. If "ABA" was a word, then this algorithm wouldn't find it.
1) Put all the seven letter long words, into a separate array of strings or file. strlen(word) could help.
2) Use nested for loops (7 of them), to represent each wheel of a 7 wheel odometer. Set each wheel to it's lowest possible value, and it's upper limit in the for loop, as it's highest possible char, according to your picture.
3) Now have the wheels find and output all permutations of the letters for you. The words from #1 should be sorted, for fast searching.
4) Use a binary search on the output of all the words you get from the "wheels". Use if((strcmp(str1, str2))==0) to find out if any permutations match a word from the 7 letter word list.
start of the code:
Code:
#include <stdio.h>
#include <string.h>
int main(void) {
char w1, w2, w3, w4, w5, w6, w7;
for(w1='a';w1<'c';w1++) {
for(w2='c';w2<'e';w2++) {
(repeat for all 7 "wheels", comparing"words"
found, with actual words from the 7 letter
word files (or array).
}
}
return 0;
}
Sound like a plan?