[Tutor] To find the least number divisible by all numbers from 1-20

2013-08-13 Thread #PATHANGI JANARDHANAN JATINSHRAVAN#
Hello All, Sorry for the earlier mail without subject. I was in a hurry so I missed that I am solving problem number 5 in project euler. I think my solution seems logically correct but it is not giving an answer as it is taking too long to execute. So can someone suggest an alternative solution

Re: [Tutor] dbus.Array to string

2013-08-13 Thread Marc Tompkins
On Tue, Aug 13, 2013 at 8:59 AM, Amit Saha wrote: > What does it mean (and will it always work?) when I don't specify any > encoding: > > >>> bytearray(ssid).decode() > u'BigPond679D85' > If you don't specify an encoding, then the default encoding is used; as you point out a bit later, your loc

[Tutor] (no subject)

2013-08-13 Thread #PATHANGI JANARDHANAN JATINSHRAVAN#
Hello All, I am solving problem number 5 in project euler. I think my solution seems logically correct but it is not giving an answer as it is taking too long to execute. So can someone suggest an alternative solution? Here is my source code: import sys def check(num): lis=[20,19,18,17,16,14,

Re: [Tutor] To find the least number divisible by all numbers from 1-20

2013-08-13 Thread Marc Tompkins
On Tue, Aug 13, 2013 at 9:45 AM, #PATHANGI JANARDHANAN JATINSHRAVAN# < jatinshr...@e.ntu.edu.sg> wrote: > Hello All, > > Sorry for the earlier mail without subject. I was in a hurry so I missed > that > > I am solving problem number 5 in project euler. I think my solution > seems logically corre

Re: [Tutor] To find the least number divisible by all numbers from 1-20

2013-08-13 Thread Alan Gauld
On 13/08/13 17:45, #PATHANGI JANARDHANAN JATINSHRAVAN# wrote: def check(num): lis=[20,19,18,17,16,14,13,11] #because a no. divisible by 20 is for i in lis: if num%i==0: continue else: return False break return True This is a bit convoluted. All you nee

Re: [Tutor] To find the least number divisible by all numbers from 1-20

2013-08-13 Thread Alan Gauld
On 13/08/13 18:19, Alan Gauld wrote: On 13/08/13 17:45, #PATHANGI JANARDHANAN JATINSHRAVAN# wrote: def check(num): lis=[20,19,18,17,16,14,13,11] #because a no. divisible by 20 is for i in lis: if num%i==0: continue else: return False break return True

Re: [Tutor] [Spoiler alert] Re: To find the least number divisible by all numbers from 1-20

2013-08-13 Thread Oscar Benjamin
On Aug 13, 2013 7:21 PM, "Peter Otten" <__pete...@web.de> wrote: > > Peter Otten wrote: > > > I'll post a naive implementation of that idea in a follow-up. > > So there: > > def gcd(a, b): > if a == b: > return a > elif a > b: > return gcd(a-b, b) > else: > retur

Re: [Tutor] dbus.Array to string

2013-08-13 Thread Steven D'Aprano
On 14/08/13 02:49, Marc Tompkins wrote: On Tue, Aug 13, 2013 at 8:59 AM, Amit Saha wrote: What does it mean (and will it always work?) when I don't specify any encoding: bytearray(ssid).decode() u'BigPond679D85' If you don't specify an encoding, then the default encoding is used; as you