def assign_space(total_size, specs):
 total_weight = 0.0
 for spec in specs:
  total_weight += float(spec.weight)
 for spec in specs:
  num_blocks = int(((float(spec.weight) / total_weight) * (total_size / float(spec.size))))
  spec.set_count(num_blocks)
  total_size -= (num_blocks * spec.size)
  total_weight -= spec.weight

def assign_space ( total_size , specs ) : total_weight = 0.0 for spec in specs : total_weight += float ( spec . weight ) for spec in specs : num_blocks = int ( ( ( float ( spec . weight ) / total_weight ) * ( total_size / float ( spec . size ) ) ) ) spec . set_count ( num_blocks ) total_size -= ( num_blocks * spec . size ) total_weight -= spec . weight
satisfy all the partitionspecs according to their weight .