Hello! I'm fairly new to java programming, and I thought, having projects was a good idea! We had a schoolproject recently, which gave me this idea. So a inputreader class is already in check! It reads strings from a txt.file.
I'm afraid this needs some patience to look through...
I want the user to input whatever characters he/she has.
Then I want my program to split up that word into characters: for eg. user enters: flog. Program reads it as: f, l, o, g.
Then shuffle each character, until it matches a word in a dictionary, in a txt.file.
For eg: golf.
Now: Firstly I got a program that did this... But it would try to match with an extremely inefficcient way: the first character randomized, then the latter char + second char randomized.
Would be much better if it could randomize all charaters (in previous example's case) at once an make a new string to check for...
Lets say user inputs 10 chars. The the program would be 90+% inefficient, if you understand what I mean. I will post sourcecode!
Then I tried a different approach: What it does, is that it takes the input in a variable, and converts it to an array of characters.
Then it adds the characters to a list, because I want to shuffle each character, then add them.... So arralist might look like: [f, l, o, g]
...then I use stringbuilder to append each by a for each loop: So if I enter by input: flog, I might get: folg. Yeah!
But then I try to iterate that operation, and then get something like: folg, folggolf, folggolfglof, and so on, which means it has to guess the word right, the first time, which is extremely improbable.
I've written a Scrabble cheater program, and my experience is that you need a permuter (to shuffle the letters) and a sublister (because not all the letters may be used). Collections.shuffle() looks like it might work for the permuter if you use a good randomizer but you still need a sublister. I can get you an algorithm to build one if you need.
Also (slightly OT) I have three dictionary files, one for OSPD, one for TWL, and one for SOWPODS.
Small nitpick: don't write
It's better to use the interface as the type than the implementation.
All things are lawful, but not all things are profitable.