Using two coins to select a person fairly. Good evening, I would like to know if the solution to this problem, I know it can be solved because it is from  a Hungarian Olympiad. The problem is as follows: You need to fairly select a person between $n$ persons using two unfair coins for which you get to decide the odds.
This is simple if you label the people $1$ through $n$ in binary and then flip $\lceil \log_2 n \rceil$  coins to get a number in binary. If the number corresponds to a person that person gets selected, otherwise repeat the process again.
The problem here is that we need to give a bound for the number of flips before hand. I don't really know how to solve the problem now.
Thank you very much in advance.
Regards.

Here's a quite straightforward method with two coins, bounded number of throws, and both coins having rational values. First coin is unbiased; second coin has the following probability for a Head:
$$p = \frac{2^m}{n!}; m = \lfloor{\log_2(n!)}\rfloor$$
With the unbiased coin you can emulate a biased coin which has $\frac{k}{2^m}$ probability for a Head ($k$ is less than $2^m$). So, using the two coins we can emulate a coin which has probability $\frac{1}{r}$ for a Head with $1\leq r \leq n$ (just emulate with the unbiased coin a biased coin with probability $\frac{n!}{r\cdot 2^m}$ for a Head). That would be enough to select uniformly from the set of $n$ people.
Example (simplified): $n=7$. Second coin $p=\frac{8}{21}$. With $3$ throws of the unbiased coin emulate a coin of $\frac{3}{8}$; using that and one additional throw of the biased coin we emulate a coin of:
$$\frac{3}{8} \cdot \frac{8}{21} = \frac{1}{7}$$
Similarly, with 3 throws of the unbiased coin and a single throw of the biased coin we can emulate a coin of:
$$\frac{7}{8} \cdot \frac{8}{21} = \frac{1}{3}$$
So, we actually have the following 'coins' to use:
$$\frac{1}{2}, \frac{1}{3}, \frac{1}{7}$$
And these are enough to choose uniformly from a set of size $7$.
