Re: [Tutor] A fun puzzle

2007-08-25 Thread Luke Paireepinart
Dick Moores wrote: > At 12:12 PM 8/24/2007, Kent Johnson wrote: >> Dick Moores wrote: >>> At 10:22 AM 8/24/2007, Kent Johnson wrote: So you actually pasted that code into timeit.py? >>> Yeah. :-( I think I learned on the Tutor list to do it that way, but >>> I'm not sure. Thanks for showing m

Re: [Tutor] A fun puzzle

2007-08-24 Thread Kent Johnson
Dick Moores wrote: >> Using your exact code, I just got >> 0.737564690484 >> 1.17399585702 >> Which is the reverse of your result, but on a slower computer. > > That result was gotten using Ulipad. Thought I'd try it at my command > line (several times, of course--I've reported what seemed to be

Re: [Tutor] A fun puzzle

2007-08-24 Thread Ken Oliver
-Original Message- >From: Dick Moores <[EMAIL PROTECTED]> >Sent: Aug 24, 2007 4:30 PM >To: Python Tutor List >Subject: Re: [Tutor] A fun puzzle > >Dick Moores wrote: >>At 10:22 AM 8/24/2007, Kent Johnson wrote: >>>So you actually pasted that cod

Re: [Tutor] A fun puzzle

2007-08-24 Thread Dick Moores
Dick Moores wrote: >At 10:22 AM 8/24/2007, Kent Johnson wrote: >>So you actually pasted that code into timeit.py? >Yeah. :-( I think I learned on the Tutor list to do it that way, but >I'm not sure. Thanks for showing me a correct way. I hope not! >>Using timeit more conventionally I get unsurpr

Re: [Tutor] A fun puzzle

2007-08-24 Thread Dick Moores
At 12:12 PM 8/24/2007, Kent Johnson wrote: Dick Moores wrote: At 10:22 AM 8/24/2007, Kent Johnson wrote: So you actually pasted that code into timeit.py?Yeah. :-( I think I learned on the Tutor list to do it that way, but I'm not sure. Thanks for showing me a correct way. I hope not! Using timei

Re: [Tutor] A fun puzzle

2007-08-24 Thread Kent Johnson
Dick Moores wrote: > At 10:22 AM 8/24/2007, Kent Johnson wrote: >> So you actually pasted that code into timeit.py? > > Yeah. :-( I think I learned on the Tutor list to do it that way, but I'm > not sure. Thanks for showing me a correct way. I hope not! >> Using timeit more conventionally I get

Re: [Tutor] A fun puzzle

2007-08-24 Thread Dick Moores
At 10:22 AM 8/24/2007, Kent Johnson wrote: >Dick Moores wrote: This time I added "xrange(10, end, 10)" and did the timing using the template in the timeit module: template = """ def inner(_it, _timer): _t0 = _timer() from itertools import chain end = 1

Re: [Tutor] A fun puzzle

2007-08-24 Thread Kent Johnson
Dick Moores wrote: >>> This time I added "xrange(10, end, 10)" and did the timing using >>> the template in the timeit module: >>> template = """ >>> def inner(_it, _timer): >>> _t0 = _timer() >>> from itertools import chain >>> end = 100 >>> for _i in _it: >>> for

Re: [Tutor] A fun puzzle

2007-08-24 Thread Dick Moores
At 11:49 AM 8/23/2007, Kent Johnson wrote: >Dick Moores wrote: >>>Two reasons. First, looking up a name that is local to a function >>>is faster than looking up a global name. To find the value of >>>'str', the interpreter has to look at the module namespace, then >>>the built-in namespace. Thes

Re: [Tutor] A fun puzzle

2007-08-23 Thread Kent Johnson
Dick Moores wrote: >> Two reasons. First, looking up a name that is local to a function is >> faster than looking up a global name. To find the value of 'str', >> the interpreter has to look at the module namespace, then the >> built-in namespace. These are each dictionary lookups. Local values

Re: [Tutor] A fun puzzle

2007-08-23 Thread Dick Moores
At 08:20 AM 8/23/2007, Kent Johnson wrote: >Dick Moores wrote: >>At 07:34 PM 8/22/2007, Kent Johnson wrote: >>>FWIW here is my fastest solution: >>> >>>01 from itertools import chain >>>02 def compute(): >>>03 str_=str; int_=int; slice_=slice(None, None, -1) >>>04 for x in chain(xrange(1,

Re: [Tutor] A fun puzzle

2007-08-23 Thread Kent Johnson
Dick Moores wrote: > At 07:34 PM 8/22/2007, Kent Johnson wrote: >> FWIW here is my fastest solution: >> >> 01 from itertools import chain >> 02 def compute(): >> 03 str_=str; int_=int; slice_=slice(None, None, -1) >> 04 for x in chain(xrange(1, 101, 10), xrange(2, 101, 10), >> 05 x

Re: [Tutor] A fun puzzle

2007-08-23 Thread Dick Moores
At 07:34 PM 8/22/2007, Kent Johnson wrote: >FWIW here is my fastest solution: > >01 from itertools import chain >02 def compute(): >03 str_=str; int_=int; slice_=slice(None, None, -1) >04 for x in chain(xrange(1, 101, 10), xrange(2, 101, 10), >05 xrange(3, 101, 10), xrange(4, 1

Re: [Tutor] A fun puzzle

2007-08-22 Thread Kent Johnson
R. Alan Monroe wrote: > I wrote a lame, but working script to solve this in a few minutes. A > fun puzzle. FWIW here is my fastest solution: from itertools import chain def compute(): str_=str; int_=int; slice_=slice(None, None, -1) for x in chain(xrange(1, 101, 10), xrange(2, 1

Re: [Tutor] A fun puzzle

2007-08-22 Thread John Fouhy
On 23/08/07, Ian Witham <[EMAIL PROTECTED]> wrote: > An interesting sequence! I assumed the next two numbers would be 8799912, > 9899901 Hmm... http://www.research.att.com/~njas/sequences/?q=8712%2C+9801%2C+87912%2C+98901%2C+879912%2C+989901&language=english&go=Search http://mathworld.wolfram.com

Re: [Tutor] A fun puzzle

2007-08-22 Thread Eric Brunson
R. Alan Monroe wrote: > I wrote a lame, but working script to solve this in a few minutes. A > fun puzzle. > > http://weblogs.asp.net/jgalloway/archive/2006/11/08/Code-Puzzle-_2300_1-_2D00_-What-numbers-under-one-million-are-divisible-by-their-reverse_3F00_.aspx > > Fun! for x in xrange(1, 100

Re: [Tutor] A fun puzzle

2007-08-22 Thread John Fouhy
On 23/08/07, R. Alan Monroe <[EMAIL PROTECTED]> wrote: > I wrote a lame, but working script to solve this in a few minutes. A > fun puzzle. > > http://weblogs.asp.net/jgalloway/archive/2006/11/08/Code-Puzzle-_2300_1-_2D00_-What-numbers-under-one-million-are-divisible-by-their-reverse_3F00_.aspx >>

[Tutor] A fun puzzle

2007-08-22 Thread R. Alan Monroe
I wrote a lame, but working script to solve this in a few minutes. A fun puzzle. http://weblogs.asp.net/jgalloway/archive/2006/11/08/Code-Puzzle-_2300_1-_2D00_-What-numbers-under-one-million-are-divisible-by-their-reverse_3F00_.aspx Alan ___ Tutor mai