► |  | How to Design Programs Teachpacks

1 | Ht DP Teachpacks
2 | Ht DP/ 2e Teachpacks

▼ | 1 | Ht DP Teachpacks

1.1 | Manipulating Images: "image.ss"
1.2 | Simulations and Animations: "world.ss"
1.3 | Converting Temperatures: "convert.ss"
1.4 | Guessing Numbers: "guess.ss"
1.5 | Master Minding: "master.ss"
1.6 | Playing Master Mind: "master-play.ss"
1.7 | Simple Drawing: "draw.ss"
1.8 | Hangman: "hangman.ss"
1.9 | Playing Hangman: "hangman-play.ss"
1.10 | Managing Control Arrows: "arrow.ss"
1.11 | Manipulating Simple HTML Documents: "docs.ss"
1.12 | Working with Files and Directories: "dir.ss"
1.13 | Graphing Functions: "graphing.ss"
1.14 | Simple Graphical User Interfaces: "gui.ss"
1.15 | An Arrow GUI: "arrow-gui.ss"
1.16 | Controlling an Elevator: "elevator.ss"
1.17 | Lookup GUI: "lkup-gui.ss"
1.18 | Guess GUI: "guess-gui.ss"
1.19 | Queens: "show-queen.ss"
1.20 | Matrix Functions: "matrix.ss"

On this page:

show-queen

top← prev up next →

#### 1.19`` Queens: "show-queen.ss"

(require htdp/show-queen)

The teachpack provides the function show-queen, which implements a GUI for exploring the n-queens problem.

> > procedure

> > (show-queen board) → true

> board : (list-of (list-of boolean?))

The function show-queen consumes a list of lists of booleans that describes a board. Each of the inner lists must have the same length as the outer list. The trues correspond to positions where queens are, and the falses correspond to empty squares. The function returns nothing.

In the GUI window that show-queen opens, the red and orange dots show where the queens are. The green dot shows where the mouse cursor is. Each queen that threatens the green spot is shown in red, and the queens that do not threaten the green spot are shown in orange.

top← prev up next →