Advertisement
Guest User

Template

a guest
Dec 4th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 1.07 KB | None | 0 0
  1. (define (neighbours state)
  2.   (local
  3.     ;; Generates all the possible rectangles starting at the first unused square
  4.     [(define (all-rectangles grid)
  5.        'NOT_IMPLEMENTED)
  6.      
  7.      ;; Takes a rectangle and returns true if the rectangle is valid in the grid
  8.      ;; 1. Every cell is unused
  9.      ;; 2. There is only one number
  10.      ;; 3. That number is the area of the rectangle
  11.      (define (rectangle-valid? _rect grid)
  12.        'NOT_IMPLEMENTED)
  13.  
  14.      ;; Does all the work to "add" a rectangle
  15.      ;; 1. Set everything to used
  16.      ;; 2. Add the rectangle to the rectangle list
  17.      (define (add-rectangle state _rect)
  18.        'NOT_IMPLEMENTED)]
  19.  
  20.     ;; If its solved, just return an empty list
  21.     (if (solved? state) empty
  22.         ;; Otherwise, generate all possible rectangles, filter out the valid ones,
  23.         ;;     and then map over and add each rectangle to the state
  24.         (map (lambda (x) (add-rectangle state x))
  25.              (filter (lambda (x) (rectangle-valid? x (state-grid state)))
  26.                      (all-rectangles (state-grid state)))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement