Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (neighbours state)
- (local
- ;; Generates all the possible rectangles starting at the first unused square
- [(define (all-rectangles grid)
- 'NOT_IMPLEMENTED)
- ;; Takes a rectangle and returns true if the rectangle is valid in the grid
- ;; 1. Every cell is unused
- ;; 2. There is only one number
- ;; 3. That number is the area of the rectangle
- (define (rectangle-valid? _rect grid)
- 'NOT_IMPLEMENTED)
- ;; Does all the work to "add" a rectangle
- ;; 1. Set everything to used
- ;; 2. Add the rectangle to the rectangle list
- (define (add-rectangle state _rect)
- 'NOT_IMPLEMENTED)]
- ;; If its solved, just return an empty list
- (if (solved? state) empty
- ;; Otherwise, generate all possible rectangles, filter out the valid ones,
- ;; and then map over and add each rectangle to the state
- (map (lambda (x) (add-rectangle state x))
- (filter (lambda (x) (rectangle-valid? x (state-grid state)))
- (all-rectangles (state-grid state)))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement