Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PyCutRod
#python 3.6.9 ###################################### #PyCutRod:Python equivalent of CutRod program (created on September 12,2022) #this code is created by Rezaul Hoque on September 14,2022; #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; ###################################### K=100000 n=8 def max(a,b): if(a>b): return a else: return b def cutRod(p,n): if(n<=0): return 0 MaxR= -1*K for i in range(0,n): MaxR=max(MaxR,p[i] +cutRod(p,(n-i-1))) return MaxR class RC(object): def __init__(self,p,n): self.p=p self.n=n def rod(self): MaxR= -1*K for i in range(0,n): MaxR=max(MaxR,self.p[i] +cutRod(self.p,(n-i-1))) return MaxR a=[1,5,8,9,10,17,17,20] r=RC(a,n) print(r.rod())
run
|
edit
|
history
|
help
0
SceneGraph Interviewee Task
ort
Q5
Student
A list is shuffled and reshuffled till the 0th index of the list matches
HW5, SelectionSort FINNAL
3564
BasicPattern.py
List comprehension, join, split, zip
Clockwise matrix rotation