The Access Wizard Newsletter
Tips, Tricks, and Traps for Access Users and Developers.

How to Solve Tough Problems – Part 2

Introduction: The Case of the 4 Captured Soldiers

Consider the puzzle of the 4 captured soldiers. We’ll call them A, B, C and D as shown in the picture.

They cannot move, and they can only look forward. Between A and B is a solid brick wall, which cannot be seen through. They all know that between them they are wearing four hats--two black and two white. They do not know what color they are wearing. Each of them knows the position of the other men.

In order to avoid being shot, one of them must call out to the executioner the color of his hat. If he gets it wrong, everyone will be shot. They are not allowed to talk to each other and have 10 minutes to fathom it out. After one minute, one of them calls out.

Question: Which one of them calls out? Why is he certain of the color of his hat?

If you want you can immediately jump to the end to see the solution; however if you read the entire Wizard you’ll learn some skills to help you solve this logic problem as well as become more effective at solving both database problems and problems in general.

Recap

In the last Wizard, we reviewed the basics of Polya's Problem Solving Method:

  1. Understand the problem
  2. Make a plan
  3. Execute the plan
  4. Look back

In this Wizard, we review other problem-solving approaches.

Simplify the Problem

This is a truly powerful technique for solving complicated problems. If you have a problem with many interrelated parts, start taking away pieces to create a simpler problem. The goal is to get to a point where you have a problem that is simple enough to solve. What did you learn? Sometimes with this step you gain an insight to solving the larger problem. If not, then add layers of complexity back to the problem to approach the solution.

Trace the Data

In an Access database, you are almost always reading, writing, editing, or manipulating data. Interrupt your process at critical points in the program and either inspect the data to determine at what point the data is not what you expect it to be. When you reach that spot, look to the preceding code for the source of the error.
 

Explain the Problem to a Colleague (or your dog)

The amazing part of this step is that as you break down the problem into steps simple enough so that a colleague (or your dog) can understand, you will often find the light-bulb going off and see the solution.
 

Compact and Repair

Sometimes the problem lies with minor corruption of the data. This problem may be subtle enough to so that it not apparent, yet can solve many problems.
 

Leave the Problem Alone for a While

Sometimes you bang away a problem and find that you cannot reach a solution. If you get to this point, stop working on the problem. Work on something else, take a walk, play ping-pong, read a book, just stop working the problem. Strangely enough letting go of the problem allows other parts of your brain to work on it. and sometimes you will get that glorious moment when you see the solution.
 

Coming Attractions

As you can see, solving software problems can be difficult and frustrating. In the next Wizard, we’ll move to the code part of problem solving and dive into the VBA piece of the puzzle.
 

Solution to the Puzzle of the 4 Captured Soldiers

C says “I am wearing a black hat” and he’s right. He can see that the soldier in front of him is wearing a white hat. He knows that the soldier on the other side of the wall has no information since he sees nothing but a wall. He also knows that the soldier in front of him has no information since he sees nothing but a wall.

That leaves him thinking about the soldier behind him. If the soldier sees that the two men in front of him have the same color hat, then it would be obvious to him that his hat must be different than the color of the two soldiers he can see, and he would announce the solution. Soldier B, therefore can say, with reasonable certainty that he (soldier B) must be wearing a hat different than the color of the soldier in front of him. He is therefore wearing a black hat.

Tip of the Month: Compact and Repair Caveats


In the early days of Access the Compact and Repair utility would occasionally trash a data file and you’d end up worse than before you ran the process. In more recent Access versions this behavior is thankfully rare.

In any case regardless of which version of Access you’re using make a back copy of your file. If you’re not convinced that this is something you should do, check out the April 2010 Wizard to get convinced.


Quick Links:

Custom Software Home

Access Wizard Archives

Our Services

© Copyright Custom Software
All Rights Reserved | Westford, MA 01886