I am look for a way to generate in C++ all the posible arrangements of letters from a string including adding spaces so I can then check with a library to see if they are valid words and create anagrams possibly involving multiple words
You gotta have more then a starting point to go on from there. Is there a particular place your stumped or is this the class project and you want us to do your work for you. Questions are great but be realistic.
Creating a list of words isn't so bad. However creating a list of sentences would be largely impossible. The reason I'd say that is because not only would you have to create the search routine but then you'd have to determine if it's a sentence.
To get you started the grunt way would be to look at the first letter then compare it to each of the next letters to see if it forms any 2 letter words compared to a dictionary. Then you look at the 2nd letter and compare it to each of the remaining ones, then the 3rd etc.... Next you go back to the beginning and look for 3 letter combination etc.... First though you have to have your database of words to cross reference.
Don't think of it as anagrams so much think of it more as a spell checker then start googling from there.
This is a project I chose to do but the real point is to parallelize it I can write something that will check words against each other ok but I get stuck I get caught up trying to set up the algorithm to check each possible arraingment not very good with recursion its the inclusion of spaces
actually it does not need to make sense I just want words but all I want is how to generate all the permutations of the input I will check it to see if its valid w/ the dictionary at any point and if it is completely invalid
Comments
Creating a list of words isn't so bad. However creating a list of sentences would be largely impossible. The reason I'd say that is because not only would you have to create the search routine but then you'd have to determine if it's a sentence.
To get you started the grunt way would be to look at the first letter then compare it to each of the next letters to see if it forms any 2 letter words compared to a dictionary. Then you look at the 2nd letter and compare it to each of the remaining ones, then the 3rd etc.... Next you go back to the beginning and look for 3 letter combination etc.... First though you have to have your database of words to cross reference.
Don't think of it as anagrams so much think of it more as a spell checker then start googling from there.
To see what I mean. There are online Anagram Generators but they create garbage sentences.
http://www.mbhs.edu/~bconnell/cgi-bin/anagram.cgi
actually it does not need to make sense I just want words but all I want is how to generate all the permutations of the input I will check it to see if its valid w/ the dictionary at any point and if it is completely invalid