Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Ponder This: the worm-eaten page

by hv (Prior)
on Dec 17, 2004 at 13:58 UTC ( [id://415628]=note: print w/replies, xml ) Need Help??


in reply to Ponder This: the worm-eaten page

This can also be solved by arithmetic quite readily.

The sum of the digits 1 .. 9 is 45.

Each digit appears 1000 times in each of the units, 10s, 100s and 1000s places.

The units always count as themselves: total 1000 * 45.

The tens are followed by a zero 1/10 of the time: total (100 + 900 * 10) * 45.

The hundreds are directly followed by a zero 1/10 of the time, and followed by a non-zero digit then a zero 1/10 of the remaining: total (100 + 90 * 10 + 810 * 100) * 45.

Similarly for the thousands: total (100 + 90 * 10 + 81 * 100 + 729 * 1000) * 45.

So the sum is (1300 + 1080 * 10 + 891 * 100 + 729 * 1000) * 45 = 830200 * 45 = 37,359,000

This approach can readily be adapted to base b, and beyond to the eat digits 0 .. x-1 required for part 2 of the puzzle.

Hugo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://415628]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (None)
    As of 2024-04-19 00:04 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found