June 15th, 2011 0 comments

This week I am shifting to programs which require some programming to solve.

Given a string, return the largest palindrome substring. A palindrome is a string which is identical when reversed (E.G. a, aa, aba, abcba).

When you have your solution, run it on the following string:

I originally found this problem at programmingpraxis.com

June 6th, 2011 1 comment

Given a rectangular cake with a rectangular piece removed (any size or orientation), how would you cut the remainder of the cake into two equal halves with one straight cut of a knife?

June 2nd, 2011 0 comments

Given a 32 bit 2's complement number and the bitwise operation set & (and), | (or), ^ (xor), << and > (left and right shifting) define an equation or algorithm to count the number of bits which are set to 1 in the string without looping structures. Registers (variables) are allowed.

In other words: write the following C function without loops:

int set_bits_count(int input) {


May 23rd, 2011 0 comments

Three gods A, B, and C are called, in no particular order, True, False, and Random. True always speaks truly, False always speaks falsely, but whether Random speaks truly or falsely is a completely random matter. Your task is to determine the identities of A, B, and C by asking three yes-no questions; each question must be put to exactly one god. The gods understand English, but will answer all questions in their own language, in which the words for yes and no are da and ja, in some order. You do not know which word means which.

May 16th, 2011 0 comments

A great king's guards have caught an assassin leaving the wine cellar with an empty poison vial.

In the cellar there are 1000 bottles of wine and there was only enough poison for one of them. In 24 hours the king is throwing a banquet and will need to serve his wine. A single sip of the poison is deadly in 15 to 20 hours, with no symptoms showing until death.

What is the minimum number of people who have to risk their lives (voluntarily, of course) to determine exactly which bottle is poisoned?

What if there are an arbitrary number of bottles?