Le Monde puzzle [49]

Here is a quick-and-dirty solution to Le Monde puzzle posted a few days ago: the R code counts the number of winning tickets between 1 and N, and stops when there is a proportion of 10% of winning tickets.

#winning ticket

#decimal digits decomposition

for (i in 1:3)


#number of winning tickets
for (i in 1:9999){

 if ((i>999)&&(10*nwt==i)) break()}


The (only) solution is therefore N=3500. (I am using this home-made decomposition of a number into its decimal digits, but there must be some function doing that in R already!)

6 Responses to “Le Monde puzzle [49]”

  1. [...] I spent most of my Saturday perusing R codes to check the answers written by my students to the R exam I gave two weeks ago… The outcome is mostly poor, even though some managed to solve a fair part of the long problem. Except for the few hopeless cases who visibly never wrote a single line of R code before the exam, all students have managed the basics of R programming and graphics, if not of Monte Carlo approximations or of boostrapping. One of the problems involved the distribution of a disk area and I found that half of the [third year math!] students do not know the formula! Although I had repeatedly told them about the good training in trying to solve Le Monde puzzles (as well as checking my posts about them), only one student found the solution to puzzle #49… [...]

  2. [...] last puzzle of the year in Le Monde reads as follows (as far as I understand its wording!): Iter(n,x,y) is the [...]

  3. [...] Monde puzzle [52] The last puzzle of the year reads as follows (as far as I understand its wording!): Iter(n,x,y) is the [...]

  4. Placing Digits in a Number into a Vector…

    I enjoy reading about the Le Monde puzzles (and other topics!) at Christian Robert’s blog. Recently he asked how to convert a number with s digits into a numerical vector where each element of the vector contains the corresponding digit (by place valu…

  5. You could always use:
    toDigits <- function(n){
    x = as.character(n)
    d =as.numeric(strsplit(x, "")[[1]])
    lin = length(d)
    return(c(rep(0, 4-lin), d))

    Thanks for posting these!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 557 other followers