Maximum Consecutive Subsequence

Shows a solution to the classic Maximum Consecutive Subsequence problem covered in most introductory algorithms courses. It uses predicate calculus to derive the solution and gives a simple implementation in Haskell. PDF

 

Prison Cells Problem

A prison has n cells with all cell doors shut initially. The warden is a little weird so he walks the whole row of cells and opens every cell door. Then he walks the whole row again and shuts every other cell door. Then he walks the whole row again and opens every third door then walks the row again and shuts every 4th door etc. You can assume that the doors are numbered 0 to (n - 1) and the warden always starts at 0 and walks them in order. Which doors will stay open when the warden is done ? PDF

 

SkewTrees

Shows a solution to the SkewTree problem posed at the TopCoder 2003 competition. PDF

 

Twelve coins

Of twelve coins, one is counterfeit and weighs either more or less than all the others. The others weigh the same. With a balance scale, on which one side may be weighed against the other, you are to use only three weighings to determine the counterfeit. PDF

 

Bridge Crossing

Calculates all the possible ways to cross the bridge in the bridge crossing puzzle. PDF

 

Two easy pieces

Number of trailing zeros in n! and Fibolucci sequence. PDF

 

Puzzle snacks

Airplanes and coins. PDF

 

Points on a circle

Are there 4 points out of a set of points on a circle that form a rectangle? PDF

 

Finding celebrities

Finding celebrities amongst the guests at a party? PDF