Puzzle 5: Keep Those Queens Apart

Can you place eight queens on a chessboard so no two queens threaten each other? Is this even possible? Prof. Devadas explains how to write a computer program to quickly and definitively answer this question.

Flash and JavaScript are required for this feature.

Puzzle Description

Python Code

Assignment

  • Do one or more of the exercises in the Keep Those Queens Apart puzzle.

Solution

Programming Constructs and Algorithmic Paradigms Covered in this Puzzle

  • Two-dimensional lists
  • While loops
  • Continue statements and argument defaults in procedures
  • Exhaustive search via iteration
  • Conflict detection