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

The puzzle in Le Monde this week[end] is called the “square five” (sic!):

Two players each have twenty-five cards with five times each of the digits 1,2,3,4,5. They alternate putting one card on top of the pile, except that they can instead take an arbitrary number of consecutive cards from the top of the pile whose product is a squared number. In which case the corresponding player wins! What is the maximum number of moves and who can find a winning strategy?

At any time, a player cannot put a 1 or a 4 because those are squared numbers. The choice is therefore always among 2,3,5, with a prohibition of squares in the sequence. Testing blindly for the longest possible sequence can be done via the following R code

```#testing for squares
whole=function(x,tol = .Machine\$double.eps^0.5) abs(x - round(x)) < tol

#Monte Carlo loop
maxl=1
for (t in 1:10^4){

counter=matrix(5,ncol=2,nrow=5)
#random start
rounds=1
pile=sample(c(2,3,5),1)
counter[pile,1]=counter[pile,1]-1
cont=TRUE
playr=2
while (cont){

if (max(whole(sqrt(cumprod(pile[rounds:1]))))==1){
cont=FALSE
}else{
if (sum(counter[c(2,3,5),playr])==0){
newt=4 #game over!
}else{
newt=sample(c(2,3,5)[counter[c(2,3,5),playr]>0],1)
}
pile=c(pile,newt)
counter[newt,playr]=counter[newt,playr]-1
rounds=rounds+1
playr=3-playr
}
}
if (rounds>maxl)
sek=pile
maxl=max(maxl,rounds)
}
```

which gives a maximum length of 8, a figure that makes sense since picking any sequence of length 8 from 2,3,5 leads to a square by a tree decomposition. It does not seem there is a winning strategy for the second player if the first one plays in an optimal manner…
{"ft_lang_label":"__label__en","ft_lang_prob":0.862554,"math_prob":0.986719,"size":2070,"snap":"2020-45-2020-50","text_gpt3_token_len":586,"char_repetition_ratio":0.09874153,"word_repetition_ratio":0.09677419,"special_character_ratio":0.27004832,"punctuation_ratio":0.13304721,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9936935,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-11-29T02:43:37Z\",\"WARC-Record-ID\":\"<urn:uuid:4db580e8-16ad-4041-acab-36b3115946a4>\",\"Content-Length\":\"79469\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:256a5db2-28d4-4726-b57a-30ac1bc539bd>\",\"WARC-Concurrent-To\":\"<urn:uuid:0424015f-9e05-4368-a061-b61537186e37>\",\"WARC-IP-Address\":\"172.67.170.238\",\"WARC-Target-URI\":\"https://www.r-bloggers.com/2010/10/le-monde-puzzle-40/\",\"WARC-Payload-Digest\":\"sha1:RJZ3S7QDLGUEZWCYFPZQHBG2RNH453Y6\",\"WARC-Block-Digest\":\"sha1:WEC4AXV4R25V7WLR62QZ47OCWON7CLQE\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-50/CC-MAIN-2020-50_segments_1606141195967.34_warc_CC-MAIN-20201129004335-20201129034335-00033.warc.gz\"}"}