Sunday, April 6, 2008

Logic Puzzle

Twelve billiard balls all weigh the same, except for one that is either light or heavy. Determine in three weighings on a balance scale which is the "odd ball", and whether it is light or heavy.

Answer to the last Logic Puzzle:

Start 3 of the ends burning at the same time. When one rope (the one whose both ends were started burning) is completely burned out (30 minutes), light the unburned end of the other rope. By the time that rope is burned, 45 minutes will have passed.

Labels:

Wednesday, March 19, 2008

Logic Puzzle

You have two ropes, each of which takes exactly 1 hour to burn from end to end. Each rope has different material densities at different points, so there's no guarantee how long it will take different sections within the rope to burn—for instance, the first half might burn in 59 minutes and the second half in 1 minute. You need to find a way to measure exactly 45 minutes by burning these two ropes.

Answer to the last Logic Puzzle:

Take one coin from stack 1, 2 coins from stack 2, 3 coins from stack 3, etc. Take a single measurement of the 55 coins. The stack is the amount it's off from 55.0 grams / 0.1 grams. So, if it's off by 0.1 grams (54.9 grams), stack 1 contains the 0.9 gram coins. If it's off by 0.2 grams, it's stack 2, and so on.

Labels:

Sunday, March 16, 2008

Logic Puzzle

You have 10 stacks of 10 coins each. One stack is composed of coins that weigh 0.9 grams each. The other 9 stacks are composed of coins that weigh 1.0 grams each. If I gave you a scale that was accurate to 0.1 grams, how could you determine with a single measurement of any number of coins from any number of stacks, which stack contained the 0.9 gram coins?

Answer to the last Logic Puzzle:
C = chickens
E = Eggs
D = days
1.5 C * 1.5 D = 1.5 E
2.25 ( C * D ) = 1.5 E
C * D = 1.5 * E / 2.25
In other words, one chicken produces 2/3 of an egg per day, so in 3 days, a single chicken would produce 2 eggs.

Labels:

Friday, March 14, 2008

Logic Puzzle

One and a half chickens lay one and a half eggs in one and a half days. How many eggs does one chicken lay in three days?

Labels:

Wednesday, January 16, 2008

Tower of Hanoi

A classic puzzle taught in many computer science courses is the Tower of Hanoi puzzle. The concept usually being taught is recursion. Because most video game developers also have a background in computer science, it's not surprising to find this puzzle included in some video games. A popular game studio, Bioware, apparently has some developers who really enjoy this one as it's appeared in more than one of their games.

As a programmer I didn't find the puzzle all that difficult, but I was surprised to learn when browsing the game forums on Xbox.com that many gamers out there found this puzzle extremely difficult. While playing Mass Effect I actually thought the puzzle was too easy. I mean, if Bioware really wanted to challenge gamers to figure it out, they should have put more than just four discs in the puzzle. Four discs only requires 15 moves to solve.

The puzzle could easily have been used as a checkpoint for gamers. Make it difficult enough that only a select few can get by it by solving it, then (as they do) provide a way to bypass the puzzle using something readily available elsewhere in the game. In Mass Effect you can use omni-gel, a substance obtained by breaking down items you find, to bypass the puzzle. If only Bioware had made the puzzle have six or seven discs.... Then the puzzle would have taken 63 and 127 moves, respectively, to solve. It could have been used as a way to make gamers pursue the side quests in the game if they didn't have the patience to solve the puzzle.

Number of Discs:4
Move from First to Second
Move from First to Third
Move from Second to Third
Move from First to Second
Move from Third to First
Move from Third to Second
Move from First to Second
Move from First to Third
Move from Second to Third
Move from Second to First
Move from Third to First
Move from Second to Third
Move from First to Second
Move from First to Third
Move from Second to Third
# of moves = 15


Extra:
Here's my C# algorithm to solve it, for those that want to know
public long hanoi(int discs, Pegs from, Pegs to)
{
   if (discs == 1)
   {
      Console.WriteLine(string.Format("Move from {0} to {1}", Peg2String(from), Peg2String(to)));
      return 1;
   }
   Pegs other = (from == Pegs.First) ?
      (to == Pegs.Second) ?
         Pegs.Third : Pegs.Second
      : (from == Pegs.Second) ?
         (to == Pegs.First) ?
            Pegs.Third : Pegs.First
         : (to == Pegs.First) ?
            Pegs.Second : Pegs.First;
   long moves = 0;
   moves += hanoi(discs - 1, from, other);
   moves += hanoi(1, from, to);
   moves += hanoi(discs - 1, other, to);
   return moves;
}

Labels: , ,