**R – Xi'an's Og**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

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

**A** geometric Le Monde mathematical puzzle:

*Given a pizza of diameter 20cm, what is the way to cut it by two perpendicular lines through a point distant 5cm from the centre towards maximising the surface of two opposite slices?**Using the same point as the tip of the four slices, what is the way to make four slices with equal arcs in four cuts from the tip again towards maximising the surface of two opposite slices?*

**F**or both questions, I did not bother with the maths but went itself to a discretisation of the disk, counting the proportion of points within two opposite slices and letting the inclination of these slices move from zero to π/2. Unsurprisingly, for the first question, the answer is π/4, given that there is no difference between both surfaces at angles 0 and π/2. My R code is as follows, using (5,0) as the tip:

M=100 surfaz=function(alpha){ surfz=0 cosal=cos(alpha);sinal=sin(alpha) X=Y=seq(-10,10,le=M) Xcosal=(X-5)*cosal Xsinal=(X-5)*sinal for (i in 1:M){ norm=sqrt(X[i]^2+Y^2) scal1=Xsinal[i]+Y*cosal scal2=-Xcosal[i]+Y*sinal surfz=surfz+sum((norm<=10)*(scal1*scal2>0))} return(4*surfz/M/M/pi)}

The second puzzle can be solved by a similar code, except that the slice area between two lines has to be determined by a cross product:

surfoz=function(alpha,ploz=FALSE){ sinal=sin(alpha);cosal=cos(alpha) X=Y=seq(-10,10,le=M) frsterm=cosal*(10*cosal-5)+sinal*(10*sinal-5) trdterm=cosal*(10*cosal+5)+sinal*(10*sinal+5) surfz=0 for (i in 1:M){ norm=sqrt(X[i]^2+Y^2) scal1=(10*(Y[i]-5)*cosal-(10*sinal-5)*X)*frsterm scal2=-(-10*(Y[i]-5)*sinal-(10*cosal-5)*X)*frsterm scal3=(-10*(Y[i]-5)*cosal+(10*sinal+5)*X)*trdterm scal4=-(10*(Y[i]-5)*sinal+(10*cosal+5)*X)*trdterm surfz=surfz+sum((norm<=10)* ((scal1>0)*(scal2>0)+ (scal3>0)*(scal4>0)))} return(4*surfz/M/M/pi)}

a code that shows that *all* cuts lead to identical surfaces for bot sets of slices. A fairly surprising result!

Filed under: Books, Kids, R Tagged: competition, geometry, Le Monde, mathematical puzzle, optimisation, R

**leave a comment**for the author, please follow the link and comment on their blog:

**R – Xi'an's Og**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

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