title: Split a number into three buckets with constraints
body: <p>Is there a good algorithm to split a randomly generated number into three buckets, each with constraints as to how much of the total they may contain.</p>
  
  <p>For example, say my randomly generated number is 1,000 and I need to split it into buckets a, b, and c.</p>
  
  <pre><code>These ranges are only an example. See my edit for possible ranges.
  Bucket a may only be between 10% - 70% of the number (100 - 700)
  Bucket b may only be between 10% - 50% of the number (100 - 500)
  Bucket c may only be between 5% - 25% of the number (50 - 250)
  a + b + c must equal the randomly generated number 
  </code></pre>
  
  <p>You want the amounts assigned to be completely random so there's just as equal a chance of bucket a hitting its max as bucket c in addition to as equal a chance of all three buckets being around their percentage mean.</p>
  
  <p>EDIT: The following will most likely always be true: low end of a + b + c &lt; 100%, high end of a + b + c > 100%. These percentages are only to indicate acceptable values of a, b, and c. In a case where a is 10% while b and c are their max (50% and 25% respectively) the numbers would have to be reassigned since the total would not equal 100%. This is the exact case I'm trying to avoid by finding a way to assign these numbers in one pass.</p>
  
  <p>I'd like to find a way to pick these number randomly within their range in one pass.</p>