Ahh homework.. those were the days.
Brute force is a starting point..
You could load the 100 strings into an array.
You could iterate over the array
Create Map matches
For each string in array
for each letter of input
do an indexof the first letter if found store in matches(string,num times matched)
if found continue letter loop
end letter loop
end loop
iterate over matches map.entries
if value of entry == # input letters it matches
end iterate
Main Topics
Browse All Topics





by: mightyonePosted on 2005-10-11 at 14:07:25ID: 15064552
using a hsch map, wheer the values are stored in a list
keys should be all letters a,b,c,....
when reading file parse the input and ad it to valuelist if key hits e.g. seth would be filles to values to 's', 'e', 't', and 'h'
remember to update and not overwrite your value lists
e.g.
Hashmap map = new Hashmap();
//fill with empty Arraylists as values to avoid nullpointers
e.g.
map.put("a", new ArrayList());
map.put("b", new ArrayList());...
then ad the real values
List tmp = map.getValue("s");
tmp.add("seth");
map.put("s",tmp);
and so on
make sure not to print results double...