Untitled

 avatar
Darin
plain_text
a year ago
1.3 kB
1
Indexable
Never
package Day1;

class UserSolution {

	int[] check = new int[4];
	int[] res = new int[4];
	int[] A = new int[6];
	int[] visit = new int[6];
	boolean flag = false;

	boolean Bt(int k) {
		if (k == 5) {
			for (int i = 1; i <= 4; i++) {
				res[i - 1] = check[A[i] - 1];
			}
			Solution.Result temp = Solution.query(res);
			if (temp.strike == 4)
				return true;
		}
		for (int i = 1; i <= 4; i++) {
			if (visit[i] == 0) {
				A[k] = i;
				visit[i] = 1;
				if (Bt(k + 1) == true)
					return true;
				visit[i] = 0;
			}
		}
		return false;
	}

	public void doUserImplementation(int guess[]) {
		for (int i = 0; i < 6; i++) {
			visit[i] = 0;
		}
		for (int i = 0; i < 10; i++) {
			for (int j = i + 1; j < 10; j++) {
				for (int k = j + 1; k < 10; k++) {
					for (int q = k + 1; q < 10; q++) {
						check[0] = i;
						check[1] = j;
						check[2] = k;
						check[3] = q;
						Solution.Result tmp = Solution.query(check);
						if (tmp.strike == 4) {
							for (int l = 0; l < 4; l++)
								guess[l] = check[l];
							return;
						}
						if (tmp.strike + tmp.ball == 4) {
							Bt(1);
							for (int l = 0; l < 4; l++)
								guess[l] = res[l];
							return;
						}
					}
				}
			}
		}
	}
}