title: Python implementing rod cutting algorithm
body: <p>Im practicing for dynamic programming 
  and im new to python as well. 
  When I try this in the shell. </p>
  
  <pre><code>def cut_rod(p, n):
      if n==0:
          return 0
      q = float('-inf')
      for i in range(n):
          q = max(q, p[i] + cut_rod(p, n-1-i))
      return q
  
  p = [1,5,8,9,10,17,17,20,24,30]
  print(timeit.repeat("cut_rod(p, 4)", "from __main__ import cut_rod",
                number =1000))
  </code></pre>
  
  <p>It warns me that p is not a global variable. in timeit function
  Isn't p already a global variable?</p>