[an error occurred while processing this directive]
## cs150: Notes 10

#### Assignments Due

#### Lab Hours

Kinga's lab hours tomorrow will be 4-5:30pm, instead of the normally
scheduled 6-7:30pm time. Richard will have his normal lab hours tomorrow,
7:30-9pm. This afternoon, Dan will have his normal lab hours, 4-5:30pm.
Please take advantage of the scheduled lab hours to make progress on
PS3.

#### Pegboard Puzzle

First, we need a way to represent the state of a board. The way we use
is a bit strange, but will make solving the problem easier. Instead of
keeping a list of the pegs, we keep a list of the empty squares. If a
valid board position is not in the list of empty squares, it means there
is a peg at that position.
;;; A board is a pair of the number of rows and the empty squares
(define (make-board rows holes) (cons rows holes))
(define (board-holes board) (cdr board))
(define (board-rows board) (car board))
;;; A position is a pair of a row and column.
;;;
;;; make-position creates an row, col coordinate that
;;; represents a position on the board
;;; e.g. 1,1
;;; 2,1 2,2
;;; 3,1 3,2 3,3
(define (make-position row col) (cons row col))
(define (get-row posn) (car posn))
(define (get-col posn) (cdr posn))
(define (same-position pos1 pos2)
(and (= (get-row pos1) (get-row pos2))
(= (get-col pos1) (get-col pos2))))

Define a procedure `on-board?` that takes as inputs a board and a
position, and outputs true if and only if the position is on the board.

Define a procedure `remove-peg` that takes as input a board and a
position, and produces as output the board with the peg at the input
positition removed.
(define (remove-peg board posn)
(make-board (board-rows board)
_______________________))

Define a procedure `add-peg` that takes as input a board and a
position, and produces as output the board with a peg added at the input
positition. (Hint: this is much tougher.)

Next, try to solve as much of the problem as you can. You should first
think about how to simulate a jump on the board. Then, consider how to
find all the possible jumps on a given board. Finally, consider how to
search all the possible sequences of jumps to find a winning sequence.
Good luck! And remember, even if you leave two pegs, "you're purty smart".