from string import digits
chosen = "xxxx"
f_bulls = []
my_dict = {}
for i in digits:
my_dict.update({i:{
"excepect":[]
}})
def make_chosen(chosen,obj=None):
if type(obj) != int:
return ''.join(list(map(lambda x: "x" if x[0] not in obj else x[1], enumerate(chosen))))
else:
return ''.join(list(map(lambda x: "x" if x[0] == obj else x[1], enumerate(chosen))))
def int_input():
return list(map(lambda a: int(a), input().split(" ")))
def guess(chosen: str, old=None,my_digits = digits[5:] + digits[:5]):
for i in my_digits:
if chosen.count("x") == 0: break
place = chosen.index("x") if place not in my_dict[i]["excepect"] and i != old and i not in chosen:
chosen = chosen.replace("x",i,1)
if chosen.count("x") > 0:
chosen = chosen.replace("x",chosen[f_bulls[0]])
return chosen
def sure_bull(b1, chosen, f_bull: list):
copy = chosen
bulls = f_bull
i = 0
while i < 4:
if i in f_bulls:
i += 1
continue
chosen = make_chosen(chosen,i)
chosen = guess(chosen , copy[i])
print(chosen)
[b,_] = int_input()
if b == 4:
return "Out",[0,1,2,3]
if b < b1:
bulls.append(i)
i += 1
chosen = copy
return chosen,bulls
b_old, c_old = 0, 0
while b_old != 4:
chosen = guess(chosen)
print(chosen)
[b_new, c_new] = int_input()
if b_new == 4: break
if b_new == 0 or b_new <= b_old:
for i,val in enumerate(chosen):
if i not in f_bulls:
my_dict[val]["excepect"].append(i)
if b_new > b_old:
chosen,bulls = sure_bull(b_new, chosen, f_bulls)
if chosen == "Out": break
f_bulls.extend(bulls)
f_bulls = list(set(f_bulls))
chosen = make_chosen(chosen,f_bulls)
b_old, c_old = b_new, c_new
else:
chosen = make_chosen(chosen,f_bulls)
1715D - 2+ doors | 267A - Subtractions |
1582A - Luntik and Concerts | 560A - Currency System in Geraldion |
946A - Partition | 1068B - LCM |
1692E - Binary Deque | 679A - Bear and Prime 100 |
488A - Giga Tower | 14A - Letter |
1150A - Stock Arbitraging | 1552A - Subsequence Permutation |
1131F - Asya And Kittens | 1475F - Unusual Matrix |
133B - Unary | 1547A - Shortest Path with Obstacle |
624A - Save Luke | 1238A - Prime Subtraction |
1107C - Brutality | 1391B - Fix You |
988B - Substrings Sort | 312A - Whose sentence is it |
513A - Game | 1711E - XOR Triangle |
688A - Opponents | 20C - Dijkstra |
1627D - Not Adding | 893B - Beautiful Divisors |
864B - Polycarp and Letters | 1088A - Ehab and another construction problem |