Artificial intelligent assistant

Shooting the rabbit You have $21$ shots. You can shoot any of two windows $A$ and $B$. How many shots will you fire at window $A$ to maximize your chances of hitting a rabbit when: a) Rabbit's location is static i.e. it is either in window $A$ with probability $8/9$ or in window $B$ with probability $1/9$ through the duration of $21$ shots. b) Rabbit can move between the windows after each shot. The probability that rabbit will be in window $A$ is $8/9$ and for window $B$ is $1/9$ for each shot. There is one more thing: the likelihood of your shot hitting the rabbit when you fire at the window is $1/2$.

As stated in a comment, for b) always shoot at window $A$.

For a), if you shoot $n_A$ times at window $A$ and $21-n_A$ times at window $B$, your chance of hitting the rabbit is

$$ \frac89\left(1-\left(\frac12\right)^{n_A}\right)+\frac19\left(1-\left(\frac12\right)^{21-n_A}\right)\;. $$

Setting the derivative with respect to $n_A$ to zero yields

$$ \frac89\left(\frac12\right)^{n_A}=\frac19\left(\frac12\right)^{21-n_A} $$

and thus

$$ 8=2^{2n_A-21} $$

with solution $n_A=12$, so you should fire $12$ times at window $A$ and $9$ times at window $B$.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy a3888cda7a23208dfa2a43d788e53d36