Homework 4

Due: Fri 20 Feb 2004 Mon 23 Feb 2004

Turn in hard copy in class, and an electronic copy as an email attachment sent to Sandra.

  1. Do Ex. 2.42 from the SICP. Download the code to start you off here.

    Update: You must additionally write a function print-solution that takes the output of your queens function and prints the board configurations, one on each line, in the following format:

    (row1, col1) (row2, col2) (row3, col3) ... (rowN, colN))

    Therefore, (print-solution (queens 4)) must print:

    ((3, 4) (1, 3) (4, 2) (2, 1))
    ((2, 4) (4, 3) (1, 2) (3, 1))

    You do not have to sort the boards in any particular order, and the positions within a board can be in any permutation.

  2. Read these notes from Keunwoo's 24 Jan 2002 section.

    UPDATE: There is a typo in these notes. The line that reads (take-lists "hi" "bye") should instead read (take-lists '("hi" "bye")).

    1. Implement extract-subtrees.
    2. Implement extract-path.