6.S095 | January IAP 2018 | Undergraduate

Programming for the Puzzled

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.

Puzzle Description

Python Code


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


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

Course Info

As Taught In
January IAP 2018
Learning Resource Types
Lecture Videos
Programming Assignments with Examples