Resolved: what I asked was resolved, but feel free to respond with alternative methods. here the unscrambler letter is made with the answer. Project page
I am currently a student at AP Computer Science. I am working on decrypting letters that reads in a dictionary and prints a list of words with an entered alphabetic set. To do this, I create a map with Map<String,Set<String>>
in which the "earth" will be entered under the key "aerht" and in the corresponding set.
Example How Would I generate all of these:
CAKE -> ACEK
A C E K
AC CE EK
ACE CEK
ACEK
AE CK
AEK
ACK
AK
The problem I am facing is that some key values are not checked, as I am currently taking a set of numbers and alphabetical characters for example earth-> aehrt but this skips combos like aht-> hat or eht → the.
, , , . , → aehrt, a, ae, aeh, aehr, ah, ahr, ahrt, aer, aert
, , , .
[] a, e, h, r, t . , ArrayList of Set. "aehrt".
for(int z = 0; z<key.length();z++) {
Set<String> temp = new HashSet<String>();
for(String str: test.get(z))
str+=letters[z];
test.get(z).add(letters[z]);
test.get(z).addAll(test.get(z-1));
test.get(z).addAll(temp);
}