Serg wrote:... is it really best strategy?
I can't prove this in mathematical sense, but there are no much alternative strategies.
There is a broken link to a pdf ("Optimal algorithms for bulls and cows game")in the Wikipedia page. The document from the next link looks far too much essential with my (non-)installed fonts.
Assuming no repetition of digits in queries and the target,
- first query can be always 1234 (due to isomorphism);
- last query (max 7-th) obviously should satisfy constraints.
In between there are max 5 queries with < 1K possibilities each. Someone can attack these < (10^3)^5 = 10^15 approaches. Surely there are more symmetries such as independent order of some of the queries (if not all).