Perl-Sensitive Sunglasses PerlMonks

### Re: Coming soon: Algorithm::Loops

by artist (Parson)
 on Apr 12, 2003 at 01:38 UTC ( #250011=note: print w/replies, xml ) Need Help??

in reply to Coming soon: Algorithm::Loops

Points:
++tye for introducing and working hard on the problem.
++abigail-ii for providing simple solution.
++tall_man for analyzing the solution as I did.

Credits:
I have enjoyed the math puzzles long before having a chance to see computer for the first time. This puzzle is mentiond on mathpuzzle.com. It is an interesting and fun site to visit with lots of links by Ed Pegg Jr who is also a great contributor on mathworld.

Notes:
I believe the original question doesn't put any limit on number of digits in the numbers. As tall_man mentiond it's impossible to have solution with 3 or 6 numbers. According to his analysis there is also the possibility of having only 2 numbers that can add to 2003.

Approach:
What I realy enjoyed is different pathway for thinking about solving the math problem. The problem can be tackled from restricted set of views and that makes it interesting to see if you can see the easy methodology and appreciate solution provided by others. I also enjoy ACM puzzles. They servce purpose to construct powerful computational logic.

Future:
Yes, tye I would like to see Alogrithm::Loop. I believe that, I can use it.

Replies are listed 'Best First'.
Re^2: Coming soon: Algorithm::Loops (restrictions)
by tye (Sage) on Apr 12, 2003 at 07:27 UTC
I believe the original question doesn't put any limit on number of digits in the numbers

I mostly didn't assume any restrictions on the number of digits in the numbers being added. I derived the restrictions from my desire to have unique numbers and a non-trivial answer.

If I picked two digits, then I'd only have two numbers to add up (XY and YX) and so I can't get a sum of even 200. If I picked four digits, then the number of combinations to search is quite small and might be a fun challange with paper and pencil but didn't seem interesting from the angle I was tackling things. Since I started out wanting to avoid leading zeros, the space to search would be so small that even with pencil and paper it wouldn't be very interesting. (:

But with a quick change of a couple of characters, I see that adding up two 4-digit numbers (having the same digits in different orders) never gives us 2003. But of course it can't, because all such would be even modulo 9 while 2003 is odd modulo 9.

Thanks for the vote in favor of Algo.::Loops.

BTW, I have a much faster version of my code searching for optimal stamp denominations. Still not nearly as fast as I'd like (with one search still going after 120 hours of CPU). I'll post that code when I get some time.

- tye
But with a quick change of a couple of characters, I see that adding up two 4-digit numbers (having the same digits in different orders) never gives us 2003. But of course it can't, because all such would be even modulo 9 while 2003 is odd modulo 9.

Careful now, 7 * 2 = 14 == 5 (modulo 9).

In general (if I remember correctly), for any modulus q, if a does not share a factor with q there exists a b for every c such that a * b == c (modulo q).

Hugo

Create A New User
Node Status?
node history
Node Type: note [id://250011]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2021-04-12 04:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?

No recent polls found

Notices?