Showing posts with label puzzle. Show all posts
Showing posts with label puzzle. Show all posts

Saturday, 5 February 2011

The King's Prisoners

Trapped in a fairytale nightmare, you have been caught by the King of a far away land. Fortunately, it is his birthday and as is his custom, he's going to let one of his prisoners free. However, this year he has decided he will set free the wisest and most worthy of his prisoners.

So he takes you and his other two prisoners to the highest room of the highest tower of his great dark castle. It's a round room, and he's had three sets of chains built into the walls. You and the other prisoners are put in the chains so that each prisoner can see the other two prisoners. The King then brings out five little dots for all to see; three of them are white, two of them are black. "I shall put one of these dots on each of your foreheads. The first of you to tell me what colour the dot on his forehead is shall be set free! Even more, I shall give a banquet in honour of his wisdom!" says the King. Then he has you and the other prisoners blindfolded, and puts a dot on your forehead and those of the other prisoners. The blindfolds are removed...

How will you escape?

Tuesday, 25 January 2011

My friend Max...

Here's a little puzzle - I'm indebted to my colleague Nick for sharing this with me:

In computer programming, it's common to have a function that returns a maximum. For example, in Java, there's a function Math.max(double a, double b), which returns the higher of the values a and b. (If you're not familiar with programming, don't worry about the doubles, a and b are just numbers.)

So here's the challenge. Write a function that returns the higher of two values, using standard algebraic operators - i.e. addition, subtraction, multiplication, division, powers. You cannot use conditionals (if x, then y etc) or comparators (e.g. >, < or = ).

You don't even need to answer in programming code; an algebraic function that returns the higher of two numbers is sufficient.

Answers on a postcard?