> 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 higher than d1
>
> if n%3 == 0:
> d3 = findMinDepthPath(n/3)+1
> if n%2 == 0:
> d2 = findMinDepthPath(n/2)+1
>
> return min(d1,d2,d3)
>
>
> n = int(raw_input('N? '))
> print "Minimum depth = ", findMinDepthPath(n),'\n'
Doesn't this only look one level deep? Is the poster asking for
something that would traverse all possible paths and then check for
the shortest?
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor