## Author Archives: admin

## Sorting

You are given an array of n distinct integers. A swap is interchanging the value of two positions in the array. What is the minimum number of swaps required to sort the array? For example: If the array is [2,1,3], we need only 1 swap (swap 1 and 2). If the array is [2,3,1], we [Read the full story ...]

## Josephus

There are n people standing in a circle. Staring with person 2, every second person is eliminated until only 1 person survives. Who is the survivor? Example: If n=7, people are killed in the order 2,4,6,1,5,3 and person 7 survives. If n=5, persons are killed in the order 2,4,1,5 and person 3 survives. - via [Read the full story ...]

## Talmud problem

Joe owes $100 to creditor A, $200 to creditor B and $300 to creditor C. Joe dies, leaving behind an estate. Unfortunately, Joe's estate has insufficient funds to repay his creditors (yes, that's a very small estate). The question is how does one split the estate among the contestants. Here are three situations and the [Read the full story ...]

## Removing balls

You have a jar with 20 black balls and 16 white balls. At each step, 1. You remove two balls. 2. If the two balls are of the same color, you add a black ball. Otherwise you add a white ball. You repeat these steps until there is only 1 ball remaining in the jar. [Read the full story ...]