[PyAR2] Programming Challenge II - One is the Magic Number

gslindstrom at gmail.com gslindstrom at gmail.com
Mon Oct 27 23:33:26 CET 2008


This one's a little more advanced, but not too much. It comes from my  
friends at Car Talk and is this weeks "puzzler". I solved it first using  
basic math skills and some logic, but then wrote a program to confirm what  
I already knew; algebra will never let you down!! Here it is. Give it a  
shot.


One is the Magic Number

RAY: This was sent in by Martin Cohen and he says, “No offense guys but  
your puzzlers of late have been less than stellar. Not to worry. Help is on  
the way.”

Odometers on modern cars go from 0 to 999,999. There are no tenths; all the  
tenths are done by the trip odometer.

Imagine that someone managed to reach 999,999 miles. If you counted all the  
times that the digit 1 appeared, how many 1s would be counted? In doing  
this, count each time that 1 appears in a number.

So, for example, you would count 3 times for 1,101. Two times for 1,102. So  
how many times is the number 1 going to appear in going from 0 to 999,999?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/pyar2/attachments/20081027/08157713/attachment.htm>


More information about the PyAR2 mailing list