Partitioning a whole number in a particular way

  • Context: Undergrad 
  • Thread starter Thread starter robertjordan
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the problem of distributing a fixed number of pizza slices among a group of people based on their weights. Participants explore various methods and rules for allocation, emphasizing the constraints of whole slices and the relationship between weight and slice distribution.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant proposes minimizing the difference between the ratio of slices to total slices and the ratio of weight to total weight, seeking an algorithm to achieve this.
  • Another participant suggests that a more quantitative rule is needed to determine how weights influence slice distribution, questioning the criteria for allocation.
  • Some participants discuss rounding methods for calculating slices based on weight ratios, with differing opinions on whether to round up or off.
  • One participant shares examples where rounding leads to exceeding the total number of slices, highlighting the challenge of ensuring exact distribution.
  • Another participant mentions a potential solution of assigning leftover slices to the last person if the total assigned does not equal the available slices.

Areas of Agreement / Disagreement

Participants express differing views on the best method for distributing slices based on weight, with no consensus on a single approach. The discussion remains unresolved regarding the optimal algorithm or formula to ensure exact distribution while adhering to the constraints.

Contextual Notes

Participants note limitations in their proposed methods, such as issues arising from rounding and the need to avoid fractional slices. The discussion also highlights the dependency on the specific weighting philosophy adopted.

robertjordan
Messages
71
Reaction score
0
Hi,

Let W be the sum of all the people's weights, let P be the total number of pizza slices available.

If:
  • I have P slices of pizza (P<=W)
  • I have n people I want to split the pizza with
  • I want to use people's weight to determine how many slices they get (more weight -> more slices)
  • I don't want to split any slices. (I want to leave all slices whole)
  • A person cannot eat more slices than the value of their weight. (ai<=wi)

If w1, w2, ... , wn are the weights of the n people, and a1, a2, ... , an are the numbers of slices each of the n people get (where each ai is a whole number >= 0), I want to find the set {a1, ... , an} such that:

ni = 1| ai/P - wi/W |

is minimized.

Is there a formula (some uses of ceiling, floor?) or algorithm to find this set {a1, ... , an} ?
 
Last edited:
Physics news on Phys.org
robertjordan said:
Hi,

If:
  • I have P slices of pizza
  • I have n people I want to split the pizza with
  • I want to use people's weight to determine how many slices they get
  • I don't want to split any slices. (I want to leave all slices whole)
How can I decide how many slices to give each person? I know some people may end up with 0 pieces, but that's okay.

You could give all P slices to the heaviest person. Or, to the lightest.
 
In order to decide how to distribute the slices you need a more quantitative rule (or set of rules) than just "To use people's weight". Use people's weight how? For example, does a heavy, apparently well fed person get more pieces than a skinny, emaciated person or the other way around? What criteria must be met for a person to get at least one piece? And so on.

Of course you can always rely on probability. You can have the people toss coins and get a slice every time they get heads. You assign progressively fewer coin tosses to the people you think should get fewer slices following whatever weight criterion you have.
 
Shouldn’t you just take ##w_i/W## and round to the nearest 1/P
 
Dale said:
Shouldn’t you just take ##w_i/W## and round to the nearest 1/P
It depends on one's particular weighting philosophy. I tried some examples using ##(w_i/W)^n##. Positive values of ##n## favor the heavy people while negative values favor the skinny people. One can also try exponentials a la partition function, I guess.
 
Dale said:
Shouldn’t you just take ##w_i/W## and round to the nearest 1/P

Thanks for the replies.
I don't mind so much favoring someone more than others as long as:

  • (ai<=wi) is not violated
  • we assign exactly P pieces of pizza. no more, no less
  • only whole slices can be assigned (no fractions for ai)
For example, if we have

w1 = 25
w2 = 9
W = 34
P = 17

Then ROUND(P*w1/W) = 13
and ROUND(P*w2/W) = 5

Which means we've just assigned 18 pieces of pizza but we only have 17.I'm trying to find an algorithm that can ensure we give out exactly the P pieces and we also don't violate (ai<=wi).
 
Last edited:
Don’t round up. Round off. It should work unless you get exactly 0.5
 
Dale said:
Don’t round up. Round off. It should work unless you get exactly 0.5

I'm not sure what round off means.

If round off means raise anything with a decimal >= .5 the next whole number and anything with a decimal <.5 to the next whole number down, then the example will still lead to 18 pieces being assigned.
 
I think that is just because of being exactly 0.5.
 
  • #10
Dale said:
I think that is just because of being exactly 0.5.

Another example is:

w1 = 11
w2 = 39
w3 = 3
W = 53
P = 25

ROUND(P*w1/W) = 5
ROUND(P*w2/W) = 18
ROUND(P*w3/W) = 1

This sums to 24 but we have 25 pieces.
 
  • #11
robertjordan said:
This sums to 24 but we have 25 pieces.
I faced the same issue when I rounded so I solved the problem by assigning to the last person whatever number of pieces are left unassigned. Simple, no?
 
  • #12
Yup, you are right. No 0.5’s so that isn’t the problem
 

Similar threads

  • · Replies 29 ·
Replies
29
Views
6K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 30 ·
2
Replies
30
Views
5K
  • · Replies 57 ·
2
Replies
57
Views
7K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
4K