MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / main

Function main

dynamic_programming/rod_cutting.py:200–214  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

198
199
200def main():
201 prices = [6, 10, 12, 15, 20, 23]
202 n = len(prices)
203
204 # the best revenue comes from cutting the rod into 6 pieces, each
205 # of length 1 resulting in a revenue of 6 * 6 = 36.
206 expected_max_revenue = 36
207
208 max_rev_top_down = top_down_cut_rod(n, prices)
209 max_rev_bottom_up = bottom_up_cut_rod(n, prices)
210 max_rev_naive = naive_cut_rod_recursive(n, prices)
211
212 assert expected_max_revenue == max_rev_top_down
213 assert max_rev_top_down == max_rev_bottom_up
214 assert max_rev_bottom_up == max_rev_naive
215
216
217if __name__ == "__main__":

Callers 1

rod_cutting.pyFile · 0.70

Calls 3

top_down_cut_rodFunction · 0.85
bottom_up_cut_rodFunction · 0.85
naive_cut_rod_recursiveFunction · 0.85

Tested by

no test coverage detected