Weekly Pocket Money Problem

Say that there is a parent and a child, and the child wants to obtain the highest number of pocket money possible while competing against other siblings.

Here are the constraints.

  1. The parents have a fixed weekly allowance B for all children.
  2. The children have no knowledge of B.
  3. No child knows what the other sibling requests.
  4. Not every child asks for allowance money every week.
  5. The child may ask for money in increments of a dollar cwnd times as long as long as B0 for that week.
  6. If a child requests for money that would result in B<0, the child gets smacked and receives nothing.
  7. The child does not want to get smacked and want to maximize the pocket money.

Solution

The solution to the problem can be described by the following pseudo-code.

def calculate_threshold(smack_num, initial_cwnd=1, security_coefficient=0.5):
	cwnd = initial_cwnd
	while cwnd < smack_num:
		cwnd *= 2
	return cwnd * security_coefficient

def calculate_cwnd(weeks, threshold, initial_cwnd=1):
	cwnd = initial_cwnd
	for week in range(1, weeks + 1):
		print(f"Week {week}: cwnd = {cwnd}")
		requests = int(cwnd)
		for _ in range(requests):
			if cwnd <= threshold:
				cwnd += 1
			else:
				cwnd += 1 / cwnd

Although not described above, if the child gets smacked at any point, then a new threshold is calculated using that cwnd.

Example Problem

A child starts numbering weeks from 0 (zero) when he get smacked. On Week 0 he got smacked when he asked 24 dollars.  Assuming that the child asks for money each week, the child will ask for d dollars on Week 5.


Week 0: In this example, we know the threshold from week 0. Since knowing the threshold entails getting smacked, we won't be receiving any more money for this week.

Week 1: We start at week 1 with cwnd=1. This means that we have one request available for $1 for week 1. Since it is less than the threshold, we end the week with cwnd=1+1=2.

Week 2: Since cwnd=2, we have two requests available for a total of 2 dollars. cwnd=2+1=3 for the first request of week 2, then cwnd=3+1=4 for the second request.

Week 3: We start off with cwnd=4, and four requests would result in cwnd=4+1+1+1+1=8.

Week 4: This week is especially important because we will surpass our threshold in this week. We start with cwnd=8, which means we need to make 8 requests this week.

  1. cwnd=8 is under the threshold: cwnd=8+1=9.
  2. cwnd=9 is under the threshold: cwnd=9+1=10.
  3. cwnd=10 is under the threshold: cwnd=10+1=11.
  4. cwnd=11 is under the threshold: cwnd=11+1=12.
  5. cwnd=12 is at the threshold: cwnd=12+1=13.
  6. cwnd=13 is over the threshold: cwnd=13+113=1701313.076923.
  7. cwnd=17013 is over the threshold: cwnd=17013+117013=17013+13170=29069221013.15339.
  8. cwnd=290692210 is over the threshold: cwnd=290692210+221029069=8498908616424249013.23.

Week 5: The child will make cwnd13.23 requests for the week. If we make the assumption that each request results in a dollar, then d=cwnd=13.23. Therefore, the answer is 13.23 dollars.

In practicality, however, it may be difficult to calculate precisely the values for when it is over the threshold. We can use a general approximation that may be useful on an exam where calculator functionality is limited.

For every iteration over the threshold, we can increment n. Then we use the cwnd at the first iteration, and use the approximation cwnd=cwnd+ncwnd. If we apply this to week 4 past step 6, we would get cwnd=cwnd+ncwnd=13+31313.23.