Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

A quick riddle from The Riddler, where a multiple step game sees a probability of a 3 point increase of .4 and a probability of a 1 point increase of .3 with a first strategy (A), versus a probability of a 3 point increase of .4 and a probability of a 1 point increase of .3 with a second strategy (B), and a sure miss third strategy (C). The goal is to optimise the probability of hitting exactly 3 points after 4 steps.

The optimal strategy is to follow A while the score is zero, C when the score is 3, and B otherwise. The corresponding winning probability is 0.8548, as checked by the following code

win=function(n=1,s=0){
if(n==4)return((s==3)+.4*(!s)+.8*(s==2))
else{return(max(c(
.4*win(n+1,s+3)+.3*win(n+1,s+1)+.3*win(n+1,s),
.1*win(n+1,s+3)+.8*win(n+1,s+1)+.1*win(n+1,s),
win(n+1,s))))}}