title: Splitting number into bands for variable rate billing, ie "tiered pricing"
body: <p>I have a problem that's simple on paper, but I'm struggling to work out in code. Before I go any further, <strong>this is not a string splitting question</strong>.</p>
  
  <p>I have what is essentially a banded timesheet application. The scale is variable based on client but an example is the first three hours in a month are 80, the next three hours are 70 and remainder are 50. I currently represent this in code as:</p>
  
  <pre><code>scale = [80, 80, 80, 70, 70, 70, 50]
  </code></pre>
  
  <p>... But I'm open to suggestions there too.</p>
  
  <p>The scale and number of steps are —and have to be— variable. Some of my billing is much more simple with some clients but I like to be able to offer this high-usage plan.</p>
  
  <p>But how do I take a number of hours worked (eg 15.2) and calculate how much they should be paying? How do I split this big number into bands? As I say, it's been easy enough to work out on paper but as I get more clients and more convoluted schemes, that's getting pretty boring. Here's how I would work it out for 15.2 hours:</p>
  
  <pre><code>3 hours at 80 = 240
  3 hours at 70 = 210
  9.2 hours at 50 = 460
  total = 910
  </code></pre>
  
  <p>While I'm at it, I'd appreciate comments for the proper names for what I'm trying to describe. And Oli, if you've landed back here in 2023, pick an easier billing scheme next time, mate.</p>