A quick pass at this finds 9 values less than 1e3 that can't be paid
with three coins:

palin=: (,1}.|.)&.":"0 , (,|.)&.":"0
coins=: /:~ palin }.i.1e4

   (}.i.1e3) -. coins,,+/~ 1e3 (>#]) coins
21 32 43 54 65 76 87 98 201

I don't know what the tenth value would be. (If I remove the "1" coin,
I get 18 values that can't be paid with three coins.)

The next problem seems straightforward:
   coins {~ I.coins e. 20191104-coins
3435343 16755761

The final example would take a bit more complexity (and time) to
solve, since 3 coins brings in more possibilities. But before I'd want
to burn time on something like that, I'd want to make sure I had
gotten the problem statement right, and the missing 10th value from
the first problem bothers me.

-- 
Raul

On Tue, Jun 18, 2019 at 11:52 PM 'Skip Cave' via Programming
<[email protected]> wrote:
>
> Interesting Problem...
>
> Skip Cave
> Cave Consulting LLC
>
>
> ---------- Forwarded message ---------
> From: R-bloggers <[email protected]>
> Date: Mon, Jun 17, 2019 at 6:13 PM
> Subject: [R-bloggers] Le Monde puzzle [#1104]
> To: <[email protected]>
>
>
> [R-bloggers] Le Monde puzzle [#1104] <https://www.r-bloggers.com> [image:
> Link to R-bloggers] <https://www.r-bloggers.com>
> ------------------------------
>
> Le Monde puzzle [#1104]
> <http://feedproxy.google.com/~r/RBloggers/~3/Dhdp0uFh-WA/?utm_source=feedburner&utm_medium=email>
>
> Posted: 17 Jun 2019 03:19 PM PDT
>
> <https://twitter.com/share>
> (This article was first published on * R – Xi'an's Og
> <https://xianblog.wordpress.com/2019/06/18/le-monde-puzzle-1104/>*, and
> kindly contributed to R-bloggers) <https://www.r-bloggers.com/>
>
> *A* palindromic Le Monde mathematical puzzle
> <https://xianblog.wordpress.com/2011/09/03/le-monde-puzzle-website/>:
>
>
> *In a monetary system where all palindromic amounts between 1 and 10⁸ have
> a coin, find the numbers less than 10³ that cannot be paid with less than
> three coins. Find if 20,191,104 can be paid with two coins. Similarly, find
> if 11,042,019 can be paid with two or three coins. *
>
> Which can be solved in a few lines of R code:
>
> coin=sort(c(1:9,(1:9)*11,outer(1:9*101,(0:9)*10,"+")))
> amounz=sort(unique(c(coin,as.vector(outer(coin,coin,"+")))))
> amounz=amounz[amounz<1e3]
>
> and produces 10 amounts that cannot be paid with one or two coins. It is
> also easy to check that three coins are enough to cover all amounts below
> 10³. For the second question, starting with n¹=20,188,102,  a simple
> downward search of palindromic pairs (n¹,n²) such that n¹+n²=20,188,102 led
> to n¹=16,755,761 and n²=3,435,343. And starting with 11,033,011, the same
> search does not produce any solution, while there are three coins such that
> n¹+n²+n³=11,042,019, for instance n¹=11,022,011, n²=20,002, and n³=6.
>
> To *leave a comment* for the author, please follow the link and comment on
> their blog: * R – Xi'an's Og
> <https://xianblog.wordpress.com/2019/06/18/le-monde-puzzle-1104/>*.
> ------------------------------
> R-bloggers.com <https://www.r-bloggers.com/> offers *daily e-mail updates
> <https://feedburner.google.com/fb/a/mailverify?uri=RBloggers>* about R
> <https://www.r-project.org/> news and tutorials
> <https://www.r-bloggers.com/search/tutorial> on topics such as: Data science
> <https://www.r-bloggers.com/search/data%20science>, Big Data,
> <https://www.r-bloggers.com/search/Big%20Data>R jobs
> <https://www.r-users.com/>, visualization (ggplot2
> <https://www.r-bloggers.com/search/ggplot2>, Boxplots
> <https://www.r-bloggers.com/search/boxplot>, maps
> <https://www.r-bloggers.com/search/map>, animation
> <https://www.r-bloggers.com/search/animation>), programming (RStudio
> <https://www.r-bloggers.com/search/RStudio>, Sweave
> <https://www.r-bloggers.com/search/sweave>, LaTeX
> <https://www.r-bloggers.com/search/LaTeX>, SQL
> <https://www.r-bloggers.com/search/SQL>, Eclipse
> <https://www.r-bloggers.com/search/eclipse>, git
> <https://www.r-bloggers.com/search/git>, hadoop
> <https://www.r-bloggers.com/search/hadoop>, Web Scraping
> <https://www.r-bloggers.com/search/Web+Scraping>) statistics (regression
> <https://www.r-bloggers.com/search/regression>, PCA
> <https://www.r-bloggers.com/search/PCA>, time series
> <https://www.r-bloggers.com/search/time+series>, trading
> <https://www.r-bloggers.com/search/trading>) and more...
>
> You are subscribed to email updates from R-bloggers
> <https://www.r-bloggers.com>.
> To stop receiving these emails, you may unsubscribe now
> <https://feedburner.google.com/fb/a/mailunsubscribe?k=42gkTfZCc6B-nnx1AjmwNPM5E-w>
> . Email delivery powered by Google
> Google, 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to