Logic Problem Grid

My wife brought home a book of logic problems recently. It’s been years since I did one of these puzzles, but I think they’re fun. These are the kind where you set up a grid, like this

Then you get a series of clues to help you identify matches. The puzzle part is that you use the process of elimination to deduce relationships that aren’t explicitly given in the clues. The only thing more fun than solving these puzzles is creating a spreadsheet that makes solving them less fun. Wait, what was that again?

The above example comes from an puzzle at puzzles.com.

This spreadsheet fills in X’s when it can be determined that a relationship doesn’t exist. For instance, when you place an asterisks to indicate that Allan’s color is Brown and you’ve already determined that Allan’s month isn’t March, the spreadsheet will fill in an X to indicate that Brown’s month isn’t March. It doesn’t, however, fill in asterisks. But when you see a row or column with only one blank cell, you know what goes there.

It is setup to help solve puzzles that have four sets of five objects. Other puzzles have more or less, but this isn’t customizable for them. You could do less, you just have to fill in a bunch of X’s for the rows and columns that aren’t applicable.

It only fills in X’s when you enter an asterisk. So if you place an X in a row or column that already has an asterisk, you have to re-enter the asterisk to make sure everything’s up to date. After about the third clue, it usually isn’t necessary to do this because there’s so much redundancy in where it places X’s. I was going to have it update for placement of X’s as well as asterisks, but the latter took enough of my time that it wasn’t worth it. But if you want to know why I didn’t disable events, that’s why.

I wanted to be able to go through the clues one time and solve the puzzle. This is possible for some puzzles, but puzzles that have relative clues, like sooner/later, higher/lower, and the like, usually require a second pass.

I really had to brute force finding where the X’s go. I tried to find a cleaner algorithm, but nothing worked. So I’m looping through all the possible cells each time an asterisk is entered. It’s very fast on my machine, but your mileage may vary.

You can download LogicPuzzles.zip, which contains one xlsm file. Sorry, I don’t have a 2003 version.

5 Comments

  1. This is actually pretty cool. You’re right though – using this spreadsheet turns a fun cerebral activity into an administrative activity.

  2. Rob van Gelder says:

    I love these puzzles. They’re like suduko without the numbers. Thanks for the link!

  3. Tim Hewison says:

    Nice macros. I’ld love to use this to solve a bigger logic puzzle – one with 6 classes and 5 options for each.

    I’d really appreciate any tips you can give an amateur on how to adapt it.

    Cheers!

  4. Ian Barclay says:

    You might want to try my downloadable Logic Puzzle Solver at http://www.logicpuzzlesolver.com. It’s not an Excel application, but written in Free Basic. It has a clunky, DOS-like feel to it, some may call it “retro”! However it can solve virtually all sizes of logic problems (only constrained by the screen size). Thanks.

  5. James C says:

    Anyone know of a program (Excel or otherwise :) that does the opposite? That is, helps you create this kind of problem. Maybe it would allow you to set up a grid and then delete information until the program tells you the puzzle is unsolvable – and even better how to write the clues?

    Ive got a grand daughter in second grade whose favorite subject is math and I’d like to expand what ‘math’ is to her to include logic and logical thinking…

Posting code or formulas in your comment? Use <code> tags!

  • <code lang="vb">Block of code goes here</code>
  • <code lang="vb" inline="true">Inline code goes here</code>
  • <code>Formula goes here</code>

Leave a Reply

Here's how to update your reports of company and nearly any web data: