Question
A hidden integer lies in the inclusive range `1..n`, where `n >= 1`. The test fixture supplies a `check(x)` callback. Your code must not implement the callback and is not given the hidden integer.
Each call to `check(x)` submits a new integer guess in `1..n`, but returns the comparison result for the **previous** submitted guess:
- the first call returns `None`;
- `-1` means the previous guess was too high;
- `0` means the previous guess was correct; and
- `1` means the previous guess was too low.
Implement:
```python
from collections.abc import Callable
Check = Callable[[int], int | None]
def find_secret(n: int, check: Check) -> int:
...
```
Return the hidden integer. The fixture validates the answer and permits at most `2 * n.bit_length()` calls to `check`. Track which guess each delayed response describes; do not apply a response to the newly submitted guess.
Explain the call complexity and how the algorithm changes if feedback can be delayed by more than one round.
## Follow-ups
1. Generalize the protocol to a fixed delay of `d` calls.
2. Handle a response that may be lost or duplicated.
3. Explain what metadata is needed when several guesses are simultaneously outstanding.