Ok, well, here's an approach that tackles the "third problem":
palin=: (,1}.|.)&.":"0 , (,|.)&.":"0
coins=: /:~ palin }.i.%:1e8
findpairs=: 3 :0
n=.coins {~ I. coins e. y-coins
r=.~./:~"1 n,.y-n
)
findatriple=:3 :0
potentialpairs=. (#~ 0 < ]) y-coins
for_p. |.potentialpairs do.
pairs=. findpairs p
if.#pairs do.
pair=. {.pairs
ndx=. (#potentialpairs)-p_index+1
r=. pair,coins {~ ndx
assert. y=+/r
r return.
end.
end.
)
findatriple 11033011
99 10901 11022011
Thanks,
--
Raul
On Thu, Jun 20, 2019 at 1:44 AM 'Skip Cave' via Programming
<[email protected]> wrote:
>
> Raul,
>
> Looking at the original source of the problem, the first question has only
> 9 solutions, not 10. So your solution is correct.
> Here's the original problem statement and solution:
> https://xianblog.wordpress.com/2019/06/18/le-monde-puzzle-1104/
> Here's my version of the solution
>
> pal=.]#~(=|.&.":&>)
>
> coins=:pal}.i.1e3
>
> (}.i.1e3)-.coins,,+/~1e3(>#])coins
>
> 21 32 43 54 65 76 87 98 201
>
>
> So only 9 answers.
>
> Skip Cave
>
>
> On Wed, Jun 19, 2019 at 2:56 PM Raul Miller <[email protected]> wrote:
>
> > I came back to think about this and I noticed a mistake:
> >
> > On Wed, Jun 19, 2019 at 10:12 AM Raul Miller <[email protected]>
> > wrote:
> > > 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.)
> >
> > That should have been:
> >
> > ... that can't be paid with less than three coins.
> >
> > I suppose it's possible that the tenth value might be zero? But then
> > the problem statement would have been "that can't be paid with one or
> > two coins" and we would have an implicit constraint against a "0"
> > coin. I do have that implicit constraint in my implementation in this
> > thread, but... I can't quite make sense of 0 being the tenth value we
> > couldn't pay with less than three coins...
> >
> > Not sure if this is of any help, though.
> >
> > --
> > Raul
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm