## Diff sort

Posted on: February 27th, 2014 by
1

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 ${1\over n-1}\sum_{i=1}^{n-1} |X[i]-X[j]|$. - via Algorithmic puzzles

## Find the missing number

Posted on: February 25th, 2014 by
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

Posted on: February 24th, 2014 by
2

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

## Shortest code

Posted on: February 23rd, 2014 by
1

Write the shortest program that outputs all prime numbers less than 1000. Your program should be in one of the following languages: C, C++, Python, Java, C#, Javascript, PhP, Ruby, Perl. The length of your code is measured in the number of characters.

## prime cube

Posted on: February 22nd, 2014 by
3

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

Posted on: February 21st, 2014 by
Suppose you have an array of size n, where each element in the array is either 0, 1 or 2. How will you compute the minimum number of swaps required to sort the array in O(n) time? - via Algorithmic Fest at Stanford

## Sorting

Posted on: February 19th, 2014 by
4

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"

## Move fly out of glass

Posted on: February 18th, 2014 by
3

Can you move two sticks so that the fly is outside the glass? -via Best Brain Teasers

## Josephus

Posted on: February 17th, 2014 by