Re: [BangPypers] list problem

2010-07-22 Thread Emil Chacko
>>> for subLi in x: ... if(xdictstart.has_key(subLi[0])): ... if(xdictstart[subLi[0]]>subLi[1]): ...xdictstart[subLi[0]]=subLi[1] ... else: ... xdictstart[subLi[0]]=subLi[1] The opposite can be done to obtain the xdictend.This is one way.There might be some easier way's but i'm not aware

[BangPypers] python speed comparison

2010-07-23 Thread Emil Chacko
Below given is solution to a puzzle( http://projecteuler.net/index.php?section=problems&id=14) in python and c Python: import time startT=time.time() maxlen=0 longest=0 for i in xrange(1,100): last=i cnt=0 while(last <> 1): cnt=cnt+1 if(last%2==0): last=last/2 else: last=3*last

Re: [BangPypers] python speed comparison

2010-08-09 Thread Emil Chacko
This implementation is really good.It's really fast compared to the initial one I posted but i didn't understand much about this memoize.I asked one of my friend he told it's python decorators.Can anyone please explain what the function memoize does. > > > Readability counts. Here is my attempt.