<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/le-monde-puzzle-1036/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://xianblog.wordpress.com/2018/01/04/le-monde-puzzle-1008-3/"> R – Xi'an's Og</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><strong><img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRsQd3v7efgSlmsNPKddzl-oQS9fZOF8a68V6KPmf5dnmI_EJ66rw" alt="" width="273" height="185">A</strong>n arithmetic <a rel="nofollow" href="https://xianblog.wordpress.com/2011/09/03/le-monde-puzzle-website/" title="Le Monde puzzle [website]" target="_blank">Le Monde mathematical puzzle</a> to conclude 2017:</p>
<blockquote>
<p><em>Find (a¹,…,a¹³), a permutation of (1,…,13) such that</em></p>
<p><em>a¹/a²+a³=a²+a³/a³+a⁴+a⁵=b¹&lt;1</em><br>
<em> a⁶/a⁶+a⁷=a⁶+a⁷/a⁷+a⁸+a⁹=a⁷+a⁸+a⁹/a⁵+a⁹+a¹⁰=b²&lt;1</em><br>
<em> a¹¹+a¹²/a¹²+a¹³=a¹²+a¹³/a¹³+a¹⁰=b³&lt;1</em></p>
</blockquote>
<p><strong>T</strong>he question can be solved by brute force simulation, checking all possible permutations of (1,…,13). But 13! is 6.6 trillion, a wee bit too many cases. Despite the problem being made of only four constraints and hence the target function taking only five possible values, a simulated annealing algorithm returned a solution within a few calls:</p>
<p><em>(a¹,…,a¹³)=(6,1,11,3,10,8,4,9,5,12,7,2,13)</em><br>
<em> (b¹,b²,b³)=(1/2,2/3,3/5)</em></p>
<p>using the following code:</p>
<pre>checka=function(a){ #target to maximise
 return(1*(a[1]/sum(a[2:3])==sum(a[2:3])/sum(a[3:5]))+
  1*(sum(a[6:7])/sum(a[7:9])==a[6]/sum(a[6:7]))+
  1*(sum(a[7:9])/(a[5]+sum(a[9:10]))==a[6]/sum(a[6:7]))+
  1*(sum(a[11:12])/sum(a[12:13])==sum(a[12:13])/
    (a[10]+a[13])))}
parm=sample(1:13)
cheka=checka(parm)
beta=1
for (t in 1:1e6){
  qarm=parm
  idx=sample(1:13,sample(2:12))
  qarm[idx]=sample(qarm[idx])
  chekb=checka(qarm)
  if (log(runif(1))&lt;beta*(chekb-cheka)){
     cheka=chekb;parm=qarm}
  beta=beta*(1+log(1.00001))
  if (cheka==4) break()}
</pre>
<p>Filed under: <a rel="nofollow" href="https://xianblog.wordpress.com/category/books/" target="_blank">Books</a>, <a rel="nofollow" href="https://xianblog.wordpress.com/category/kids/" target="_blank">Kids</a>, <a rel="nofollow" href="https://xianblog.wordpress.com/category/statistics/r-statistics/" target="_blank">R</a> Tagged: <a rel="nofollow" href="https://xianblog.wordpress.com/tag/le-monde/" target="_blank">Le Monde</a>, <a rel="nofollow" href="https://xianblog.wordpress.com/tag/mathematical-puzzle/" target="_blank">mathematical puzzle</a>, <a rel="nofollow" href="https://xianblog.wordpress.com/tag/permutation/" target="_blank">permutation</a>, <a rel="nofollow" href="https://xianblog.wordpress.com/tag/r/" target="_blank">R</a>, <a rel="nofollow" href="https://xianblog.wordpress.com/tag/simulated-annealing/" target="_blank">simulated annealing</a> <a rel="nofollow" href="https://feeds.wordpress.com/1.0/gocomments/xianblog.wordpress.com/35104/" target="_blank"><img border="0" alt="" src="https://feeds.wordpress.com/1.0/comments/xianblog.wordpress.com/35104/"></a> <img border="0" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" alt="" width="1" data-recalc-dims="1" height="1"></p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://xianblog.wordpress.com/2018/01/04/le-monde-puzzle-1008-3/"> R – Xi'an's Og</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/6yl2onqx9Fg" height="1"></a></div>