You are given an array of n real numbers. Arrange them so that the average difference between adjacent numbers is minimized. In other words, minimize .
- via Algorithmic puzzles

## Monthly Archives for February, 2014

## Find the missing number

You have an array with 99 distinct entries, each entry being an integer from 1 to 100. Find the missing number in the shortest possible time and O(1) memory.
Bonus: Now you have an array with 98 distinct entries, each entry being an integer from 1 to 100. Find the two missing entries in the shortest possible time and O(1) memory.
- via Mind your decision

## Dividing a Pizza

Consider the circle shown below:
The diameter BM is divided in to 11 equal length segments: BC,CD,DE,...LM. Then we complete semicircles with diameters CM,DM,...KM,LM on the top of BM and semicircles with diameters BC,BD,BE,....BL on the bottom of BM. These semicircles divide the circle in to 11 blade-shaped objects. Show that all blades have the same area!
- via Quora

## prime cube

7 is a prime number and 7+1=8 is a perfect cube. Can you find another prime number p such that p+1 is a perfect cube?
- via Daily Brain Teaser

## 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 need 2 swaps (swap 2 and 3, then swap 1 …

**Continue reading the story**"Sorting"## 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 Wikipedia

## Polygon in rectangle

Show that every convex polygon of area 1 is contained in some rectangle of area 2.
- via AMS puzzle corner