Blame


1 12687dd9 2023-08-04 jrmu ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 12687dd9 2023-08-04 jrmu ;; about the language level of this file in a form that our tools can easily process.
3 12687dd9 2023-08-04 jrmu #reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname |28.2|) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp")))))
4 12687dd9 2023-08-04 jrmu Exercise 28.2.1. Develop a data definition for chessboards.
5 12687dd9 2023-08-04 jrmu
6 12687dd9 2023-08-04 jrmu Hint: Use lists. Represent tiles with true and false. A value of true should indicate that a position is available for the placement of a queen; false should indicate that a position is occupied by, or threatened by, a queen. Solution
7 12687dd9 2023-08-04 jrmu
8 12687dd9 2023-08-04 jrmu A row is either
9 12687dd9 2023-08-04 jrmu 1. empty or
10 12687dd9 2023-08-04 jrmu 2. (cons bool ro)
11 12687dd9 2023-08-04 jrmu where bool is a boolean (true/false), and ro is a row.
12 12687dd9 2023-08-04 jrmu
13 12687dd9 2023-08-04 jrmu A chessboard is either
14 12687dd9 2023-08-04 jrmu 1. empty or
15 12687dd9 2023-08-04 jrmu 2. (cons r cb)
16 12687dd9 2023-08-04 jrmu where r is a row and cb is a chessboard.
17 12687dd9 2023-08-04 jrmu
18 12687dd9 2023-08-04 jrmu Specifically, an nxn chessboard is a (listof (listof booleans)) such that the length of each element in the chessboard is the same as the length of the chessboard itself. That is, the chessboard is square.