# 谷歌跪经

``````
// opponent move. 1point3acres
int max(Set<Integer> candidates, int guess) {
int res = Integer.MIN_VALUE;
for (int a = 0; a <= 4; ++a) {
for (int b = 0; b <=4; ++b) {
Set<Integer> nextLayer = filter(candidates, guess, a, b);
res = Math.max(res, min(nextLayer));
}
}
return res;
}
// player move
int min(Set<Integer> candidates) {. 1point3acres
int res = Integer.MAX_VALUE;
for (int guess : candidates) {
res = Math.min(res, max(candidates, guess));
}
return res;
}

// helper function: compute the set of candidates corresponds to given guess and a b
Set<Integer> filter(Set<Integer> candidates, int guess, a, b) {
Set<Integer> res = new HashSet<>();
for (int candidate : candidate) {
// compute a and b
int aa = 0;
int [] digits_candidate = new int[10];
int [] digits_guess = new int[10];
for (int i = 0; i < 4; ++i) {
digits_candidate[i] = candidate % 10;
digits_guess[i] = guess % 10
if (digits_candidate == digits_guess) {
++aa;
}
candidate /= 10;
guess /= 10;
}
int bb = 0;
for (int i = 0; i < 10; ++i) {
bb += Math.min(digits_candidate[i], digits_guess[i]);
}
bb -= aa;. From 1point 3acres bbs

if (aa == a && bb == b) {
}
}
return res;
}

``````

Oops, line 06 should be:

for (int b = 0; a + b <=4; ++b) {