While this brain teaser can be applied to more than programming, I think it’s a very nice one to sharpen our problem-solving solution required to do a good programming.
There were 2 people, A and B. They joined together to have a meal. Person A brought 3 loafs of bread. Person B brought 5 loafs of bread. When they’re about to start eating, Person C came and asked if he can join the meal and he did. The three of them ate equal proportion. In the end, Person C gave $8 to split between Person A and Person B.
Question is, how would you split the $8 so that Person A and Person B have their share fairly?
Wait … don’t turn the page if you don’t want the solution yet.