title: Python Integer Partitioning with given k partitions
body: <p>I'm trying to find or develop Integer Partitioning code for Python.</p>
  
  <p>FYI, Integer Partitioning is representing a given integer n as a sum of integers smaller than n. For example, an integer 5 can be expressed as <code>4 + 1 = 3 + 2 = 3 + 1 + 1 = 2 + 2 + 1 = 2 + 1 + 1 + 1 = 1 + 1 + 1 + 1 + 1</code></p>
  
  <p>I've found a number of solutions for this. <a href="http://homepages.ed.ac.uk/jkellehe/partitions.php" rel="noreferrer">http://homepages.ed.ac.uk/jkellehe/partitions.php</a> and <a href="http://code.activestate.com/recipes/218332-generator-for-integer-partitions/" rel="noreferrer">http://code.activestate.com/recipes/218332-generator-for-integer-partitions/</a></p>
  
  <p>However, what I really want is to restrict the number of partitions.</p>
  
  <p>Say, # of partition <em>k</em> = 2, a program only need to show <code>5 = 4 + 1 = 3 + 2</code>,</p>
  
  <p>if <em>k</em> = 3, <code>5 = 3 + 1 + 1 = 2 + 2 + 1</code></p>