On 03/10/15 23:20, C Smith wrote:
On Sat, Oct 3, 2015 at 11:55 AM, Alan Gauld wrote:
On 03/10/15 19:10, C Smith wrote:
Here is my modified version which I think works as you want:
def findMinDepthPath(n):
if n <= 0: raise ValueError
elif n==1:
return 0
elif n==2 or
On Sat, Oct 3, 2015 at 11:55 AM, Alan Gauld wrote:
> On 03/10/15 19:10, C Smith wrote:
>>>
>>> Here is my modified version which I think works as you want:
>>>
>>> def findMinDepthPath(n):
>>> if n <= 0: raise ValueError
>>> elif n==1:
>>> return 0
>>> elif n==2 or n==3:
>>
Thank you (Cameron and Alan) for your review and feedback. This solved the
issue perfectly!
Thank you.
On Friday, October 2, 2015 11:49 PM, Cameron Simpson
wrote:
On 03Oct2015 00:51, ALAN GAULD wrote:
>On 02/10/15 23:57, Nym City via Tutor wrote:
>>socket.gaierror: [Errno 1100
On 03/10/15 19:10, C Smith wrote:
Here is my modified version which I think works as you want:
def findMinDepthPath(n):
if n <= 0: raise ValueError
elif n==1:
return 0
elif n==2 or n==3:
return 1
else:
d1 = findMinDepthPath(n-1)+1
d2 = d3 =
> Here is my modified version which I think works as you want:
>
> def findMinDepthPath(n):
> if n <= 0: raise ValueError
> elif n==1:
> return 0
> elif n==2 or n==3:
> return 1
> else:
> d1 = findMinDepthPath(n-1)+1
> d2 = d3 = (d1+1) # initialize to
One thing you can do is to make your variable live in another
module. This is a common way to make config files, for instance.
say you have a file called config.py
which contains the single line
my_int = 0
then in your main program you can do:
import config
and start using
config.my_int
wherev
On 03/10/15 09:23, Anshu Kumar wrote:
Hi Alan,
I have given a wrong example of 16 . I am sorry for it. You are
correct it will take only 4 turns.
If i consider your solution for number 10
it will go like this 10-->10/2 =5 --> 5-1=4--> 4/2 =2-->2/2 =1 which
gives 4 as output but answer would
Hi Alan,
I have given a wrong example of 16 . I am sorry for it. You are correct it
will take only 4 turns.
If i consider your solution for number 10
it will go like this 10-->10/2 =5 --> 5-1=4--> 4/2 =2-->2/2 =1 which gives
4 as output but answer would be in 3 steps 10-->10-1=9-->9/3=3-->3/3=1
>it works fine with global variable or a list type parameter for depth but i
>am looking for a way where i would be able to use a parameter which will be
>shared across all invocation and it should certainly not be a list coz i
>don't need a list
>
>Thanks and appreciate your help,
>Anshu
I am not
On 03/10/15 03:46, Anshu Kumar wrote:
Hi Alan,
I was trying to solve a simple dynamic programming problem.
It goes like this. I have an input integer and i can choose to divide it by
two or three or subtract by one to reduce it to one. there is a condition
the number has to be divisible by 2 or
Hi Alan,
I was trying to solve a simple dynamic programming problem.
It goes like this. I have an input integer and i can choose to divide it by
two or three or subtract by one to reduce it to one. there is a condition
the number has to be divisible by 2 or 3 if we are dividing by two or three
re
11 matches
Mail list logo