Hungry kids!

100 chocolate donuts and 40 strawberry donuts are randomly placed in a long line.

Two hungry kids decide to split the donuts equally so that each gets 50 chocolate donuts and 20 strawberry donuts. (Yes, they are both super hungry and have amazing metabolisms!)

Is it possible to do so, so that one kid simply pulls out a section of the long line consisting of 70 donuts, and the other kid takes what is left over on either side?

For example, one kid might take all the ones from 33 through 102, and the other would take the donuts remaining.


Assumptions : No splitting of any donuts is allowed.

Image credit: http://media.gettyimages.com

Inspiration

It depends on the initial distribution. No, never. Yes, always.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

A wonderful solution to this problem can be found in the following video by 3Blue1Brown. Have a look. https://youtu.be/yuVqxCSsE7c

Also here!

Necklace-Splitting Problem

Geoff Pilling - 2 years, 6 months ago
Geoff Pilling
Nov 27, 2018

Start by splitting the line right down the middle. Now either the left or right half must contain either (a) too many chocolate donuts, (b) too many strawberry donuts, or (c) has just the right number of each (in which case you are done).

If it is (a) or (b) simply take the next "chunk", i.e. numbers 2 through 71. Now you have either stayed the same or traded one type for the other. Since you only go up or down by one donut of each type as you slowly move the "chunk" from left to right, at some point you will have exactly 50 chocolate donuts at 20 strawberry donuts at which point you stop.

This works since if you keep going to the end, you will go from having too many chocolates to having too many strawberries, or vice versa.


Bonus question : Any thoughts on how this generalizes to m m kids with n n types of donuts? (cc'ing @Brian Charlesworth who always gets me thinking about generalizing all the answers! :) )

@Geoff Pilling : why not by applying your algorithm to go only one donuts we could have any permutation we want

al z3b - 2 years, 5 months ago

We can simply split them as 10(S)+50(C)+20(S)+50(C)+10(S) Now from anywhere you start and take 70 Donuts in a row then you will always get the correct distribution

Hardik Jain - 2 years, 4 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...