I passed the whole last night thinking. THIS DEFINETELY CONTAINS A SPOILER
So i did it in python
, and my algorithm steps where those:
- Create a words.txt file where i would paste the provided list of scrabbled words
- Grab each line from wordlist.txt and append it in a wordlist array, same with words.txt and words array . Before appending lines in those arrays, remove \n\t\r characters and spaces (because pasting the list from hts to the words.txt could be messy)
- For each element of words array, scan the wordlist array and: if the scrabbled word is of the same length as the unscrabbled word
- Then for each element (character) of the scrabbled word if it exists in the unscrabbled word DELETE the character from the position in which it was found in the unscrabbled word and now get back to the loop with the new (without the deleted character) unscrabbled word
- When this new unscrabbled word is equal to a zero length string ( == '' ) you can be sure that you got the right word
I dont know if there is any case in which those steps could return a false answer.
but i am almost sure that this is not the only solution and i would like it if any of you could post or pm me other ideas.
-- Sun Feb 16, 2014 5:29 pm --
It's a bit more mathematical...
It's based on the uniqueness of the factorisation of an integer into product of prime numbers.