Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PyCutRod(BotUp)
#python 3.6.9 ###################################### #PyCutRod(BotUp):Python equivalent of CutRod(BottomUp)program (created on September 12,2022) #this code is created by Rezaul Hoque on September 14,2022;update: 15:48 #contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com #note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; ###################################### n=8 class RC(object): def __init__(self,p,n): self.p=p self.n=n def cutRod(self): if(n<=0): return 0 r=[-1]*(self.n+1) r[0]=0 for i in range(1,self.n+1): MaxR= -1 for j in range (1,i+1): temp=self.p[j]+r[i-j] if MaxR<temp: MaxR=temp r[i]=MaxR return MaxR a=[0,1,5,8,9,10,17,17,20] r=RC(a,n) print(r.cutRod())
run
|
edit
|
history
|
help
0
My Intro
Bmi calculator dictionary
Z Pattern ( first python program)
convert hours into min
Q2
Lesson4
Greatest Common Factor (Euclidean algorithm, aka Euclid's algorithm)
Add missing names
gj
snake water gam correct