Brute-force method of finding all permutations of five characters
Set permutations = new HashSet();
for (int i = 10000; i < 99999; i++) {
Set characters = new HashSet(Arrays .asList((i+"") .split("")));
characters .removeAll( Arrays .asList(("06789") .split("")));
if (characters .size() == 5) { permutations .add(i+""); }
}
for (int i = 10000; i < 99999; i++) {
Set characters = new HashSet(Arrays .asList((i+"") .split("")));
characters .removeAll( Arrays .asList(("06789") .split("")));
if (characters .size() == 5) { permutations .add(i+""); }
}
0 Comments:
Post a Comment
<< Home