**A**n algorithmic Le Monde mathematical puzzle with a direct

Alice and Bob play a game by picking alternatively one of the remaining digits between 1 and 10 and putting it in either one of two available stacks, 1 or 2. Their respective gains are the products of the piles (1 for Alice and 2 for Bob).

The problem is manageable by a recursive function

facten=factorial(10) pick=function(play=1,remz=matrix(0,2,5)){ if ((min(remz[1,])>0)||(min(remz[2,])>0)){#finale remz[remz==0]=(1:10)[!(1:10)%in%remz] return(prod(remz[play,])) }else{ gainz=0 for (i in (1:10)[!(1:10)%in%remz]){ propz=rbind(c(remz[1,remz[1,]>0],i, rep(0,sum(remz[1,]==0)-1)),remz[2,]) gainz=max(gainz,facten/pick(3-play,remz=propz))} for (i in (1:10)[!(1:10)%in%remz]){ propz=rbind(remz[1,],c(remz[2,remz[2,]>0],i, rep(0,sum(remz[2,]==0)-1))) gainz=max(gainz,facten/pick(3-play,remz=propz))} return(gainz)}}

that shows the optimal gain for Alice is 3360=2x5x6x7x 8, versus Bob getting 1080=1x3x4x9x10. The moves ensuring the gain are 2-10-…