Re: [Tutor] self keyword in recursive function

2014-05-31 Thread Ritwik Raghav
That's all the code I'm writing. As for the reference to line 182, I have no idea since my code doesn't have line 182. Also, as Peter wrote: "The "topcoder" site is probably infested with the world view of Java where every function is a method inside a class." Topcoder seems too much in love wit

Re: [Tutor] self keyword in recursive function

2014-05-31 Thread Alan Gauld
On Fri, May 30, 2014 at 10:16 PM, Ritwik Raghav mailto:ritwikragha...@gmail.com>> wrote: and the error is: Correct Return Value: No Answer check result: Result must be not null. Execution Time: 0.017s Peak memory used: 24.551MB abnormal termination (exit 1)

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Marc Tompkins
On Fri, May 30, 2014 at 11:06 PM, Ritwik Raghav wrote: > That's all the code I'm writing. > That can't be true - the 11 lines of code you posted doesn't include anything that would give you "Correct Return Value: No", let alone any reference to PersistentNumber. From the error message, it would

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Ritwik Raghav
That's all the code I'm writing. The complete problem statement is: http://pastebin.com/E970qYXk On Sat, May 31, 2014 at 11:25 AM, Marc Tompkins wrote: > On Fri, May 30, 2014 at 10:16 PM, Ritwik Raghav > wrote: > > >> It has again given some error I do not understand. This time my code is: >>

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Marc Tompkins
On Fri, May 30, 2014 at 10:16 PM, Ritwik Raghav wrote: > It has again given some error I do not understand. This time my code is: > > count = 0 > def getPersistence(self,n): > > product = 1 > if len(str(n)) == 1: > return self.count > else: > a = str(n) > for

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Ritwik Raghav
Peter Otten wrote: >Ritwik Raghav wrote: > >> I joined the topcoder community tomorrow and tried solving the >> PersistentNumber problem: >> "Given a number x, we can define p(x) as the product of the digits of x. >> We can then form a sequence x, p(x), p(p(x))... The persistence of x is >> then d

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Ritwik Raghav
Alan Gauld wrote: >On 30/05/14 14:14, Ritwik Raghav wrote: >> I joined the topcoder community tomorrow and tried solving the >> PersistentNumber problem: > >Time travel! I love it already... :-) > >> 8*1 = 8. Thus, the persistence of 99 is 2. You will be given n, and you > >must return its persist

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Peter Otten
Ritwik Raghav wrote: > I joined the topcoder community tomorrow and tried solving the > PersistentNumber problem: > "Given a number x, we can define p(x) as the product of the digits of x. > We can then form a sequence x, p(x), p(p(x))... The persistence of x is > then defined as the index (0-base

Re: [Tutor] self keyword in recursive function

2014-05-30 Thread Alan Gauld
On 30/05/14 14:14, Ritwik Raghav wrote: I joined the topcoder community tomorrow and tried solving the PersistentNumber problem: Time travel! I love it already... :-) 8*1 = 8. Thus, the persistence of 99 is 2. You will be given n, and you must return its persistence." It asks to define a fun

[Tutor] self keyword in recursive function

2014-05-30 Thread Ritwik Raghav
I joined the topcoder community tomorrow and tried solving the PersistentNumber problem: "Given a number x, we can define p(x) as the product of the digits of x. We can then form a sequence x, p(x), p(p(x))... The persistence of x is then defined as the index (0-based) of the first single digit num