I have a method that goes through possible states on the board and saves them in a HashMap
void up(String str){
int a = str.indexOf("0");
if(a>2){
String s = str.substring(0,a-3)+"0"+str.substring(a-2,a)+str.charAt(a-3)+str.substring(a+1);
add(s,map.get(str)+1);
if(s.equals("123456780")) {
System.out.println("The solution is on the level "+map.get(s)+" of the tree");
}
}
}
I'm interested in a group of keys. What to do to print them all?
HashSet t = map.keySet() rejected by the compiler as well
LinkedHashSet t = map.keySet()
source
share