## Problem #016 β hamburger dilemma

I mixed up my hamburgers while cooking. Can you help me out?

This post's problem is brought to you by my struggles while cooking. I bought 4 raw chicken hamburgers; two of them were plain chicken burgers, the other two were already seasoned, "american-style" (whatever that meant). In practice, I could tell them apart because the american-style burgers were orange and the plain chicken burgers were light-pinkish.

I had never had one of those "american-style" (AS) burgers and I was slightly afraid I wouldn't enjoy them, so I decided I would have half of a regular burger and half of the AS burger for dinner.

I started cooking the burgers, and at some point I couldn't tell them apart by colour any more, as you can see in the picture below: they all looked the same colour!

I panicked a little bit. How can I be sure that for my dinner I will only have half of a regular burger and half of an AS burger? Of course in my mind I couldn't just take a bite of each, because that is not mathematical, so I had to come up with some way of doing it! (As sad as it might be, this is a true story...)

# Problem statement

Given 4 perfectly identical, indistinguishable hamburgers (2 regular burgers and 2 AS burgers), how can I come up with a way of serving them, such that I am able to guarantee that on my plate I have exactly half of a regular burger and exactly half of an AS burger?

# Solution

Slice each hamburger in four. Serve yourself a quarter of each hamburger. Now you have half of a regular burger on your plate and half of an AS burger. Easy, right?

This burger dilemma turns out to be equivalent to another logic riddle I was told. In this riddle, a man is in a deserted island with 4 pills: two pills of type $$A$$ and two pills of type $$B$$. Both types of pills are, of course, perfectly indistinguishable. The man needs to take 1 pill of each type right now, or he will die. He must take them at the same time and the dosage must be exactly this: 1 pill of each type. How can he do that?

The solution is pretty similar to that of my hamburger dilemma: break each pill into half; from each whole pill, take one of the halves in your hand. Take those 4 halves all at the same time. This works because among the 4 halves, the man will be holding two halves from a type $$A$$ pill and two halves from a type $$B$$ pill.

## Become a better Python π developer π

+35 chapters. +400 pages. Hundreds of examples. Over 30,000 readers!

My book βPydon'tsβ teaches you how to write elegant, expressive, and Pythonic code, to help you become a better developer. >>> Download it here ππ.