Did you solve it? The science of streaming

Earlier today I posed the following puzzle, repeated here with its solution.

Inspiration for the problem is one of the oldest, and most important streaming algorithms, the predecessor to the technology used by streaming services such as Netflix and Spotify.

The heist -head of the big ballot

An election takes place between candidates A, B, C and D. You receive a set of 100 completed ballots and your job is to determine if one of the candidates has an overall majority, i.e. has won 51 votes or more. If a candidate did, you must say who it is.

But there is a catch. You are not allowed to count ballots. That is, you are not allowed to use numbers in any way. You cannot write anything down, nor are you allowed to keep track of the count in your memory. Instead, you'll have to devise a smart strategy that involves making instant decisions on each ballot as you see it.

Anything you're allowed to do is to move the ballots between three piles on a table. The starting position, as shown below, has all the papers in a stack on the first stack. The ballots are face up, so you can always see which candidate received a vote on the ballot at the top of the stack. There are two more positions for the stacks, but they are still empty.

In the beginning stack 1 has 100 ballots and the other two stacks have zero paper

There are only two options to get started. You move the ballot from the top of stack 1 to stack 2 or stack 3. For your next move, you can do the same thing again, or you can move the ballot that is on stack 2 or stack 3. stack 3 to another stack. And so on. At any time, all you can do is move the ballot that is at the top of one pile to the top of another pile.

Your task is to come up with a strategy that tells you if a candidate has an overall majority (i.e. 51 or more votes) simply by moving ballots between piles. Can you do it?

The hint

As is often the case, it is helpful to simplify the problem to see if that gives us any ideas. Consider the case where there are only 2 candidates, A and B.

A simple strategy is: if we see A at the top of the first stack, we put it on the second pile, and if we see B at the top of the first pile, we put it on the third pile. After 100 throws, the first pile will be empty, the second pile will have all A's, and the third pile will have all B's. We can now determine which pile has the most ballots by alternately placing them back on the first pile. If there are ballots left on the second pile at the end, then A has at least 51 votes, and if there are ballots left on the third pile, then B has them. Call it the "two-group strategy".

Now try moving to...

Did you solve it? The science of streaming

Earlier today I posed the following puzzle, repeated here with its solution.

Inspiration for the problem is one of the oldest, and most important streaming algorithms, the predecessor to the technology used by streaming services such as Netflix and Spotify.

The heist -head of the big ballot

An election takes place between candidates A, B, C and D. You receive a set of 100 completed ballots and your job is to determine if one of the candidates has an overall majority, i.e. has won 51 votes or more. If a candidate did, you must say who it is.

But there is a catch. You are not allowed to count ballots. That is, you are not allowed to use numbers in any way. You cannot write anything down, nor are you allowed to keep track of the count in your memory. Instead, you'll have to devise a smart strategy that involves making instant decisions on each ballot as you see it.

Anything you're allowed to do is to move the ballots between three piles on a table. The starting position, as shown below, has all the papers in a stack on the first stack. The ballots are face up, so you can always see which candidate received a vote on the ballot at the top of the stack. There are two more positions for the stacks, but they are still empty.

In the beginning stack 1 has 100 ballots and the other two stacks have zero paper

There are only two options to get started. You move the ballot from the top of stack 1 to stack 2 or stack 3. For your next move, you can do the same thing again, or you can move the ballot that is on stack 2 or stack 3. stack 3 to another stack. And so on. At any time, all you can do is move the ballot that is at the top of one pile to the top of another pile.

Your task is to come up with a strategy that tells you if a candidate has an overall majority (i.e. 51 or more votes) simply by moving ballots between piles. Can you do it?

The hint

As is often the case, it is helpful to simplify the problem to see if that gives us any ideas. Consider the case where there are only 2 candidates, A and B.

A simple strategy is: if we see A at the top of the first stack, we put it on the second pile, and if we see B at the top of the first pile, we put it on the third pile. After 100 throws, the first pile will be empty, the second pile will have all A's, and the third pile will have all B's. We can now determine which pile has the most ballots by alternately placing them back on the first pile. If there are ballots left on the second pile at the end, then A has at least 51 votes, and if there are ballots left on the third pile, then B has them. Call it the "two-group strategy".

Now try moving to...

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow