public class PasswordXGuessing {
public static void main(String args[]) {
new PasswordXGuessing();
}
public PasswordXGuessing() {
String[] g = {"4747", "4747", "4747", "4747"};
System.out.println(howMany(g));
}
public long howMany(String[] guesses) {
long result = 0;
if (guesses.length == 1)
return 9;
else if(guesses[0].length()==1)
return 10-guesses.length;
int bits = guesses[0].length();
long s = (int) Math.pow(10, bits - 1);
long e = (int) Math.pow(10, bits);
for (long i = s; i < e; i++) {
boolean meet = true;
for (int j = 0; j < guesses.length; j++) {
// System.out.println(i);
// System.out.println(guesses[j]);
if (!chayige(i, guesses[j])) {
meet = false;
break;
}
}
if (meet)
result++;
}
return result;
}
private boolean chayige(long string1, String string2) {
// TODO Auto-generated method stub
boolean meet = false;
String num1 = string1 + "";
String num2 = string2;
for (int i = 0; i < num1.length(); i++) {
if (num1.charAt(i) != num2.charAt(i)) {
if (meet == false)
meet = true;
else
return false;
}
}
return true;
}
}