Skip to content

Instantly share code, notes, and snippets.

@stevenleeg
Created December 1, 2013 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenleeg/89568e4ad9fcbb3025c0 to your computer and use it in GitHub Desktop.
Save stevenleeg/89568e4ad9fcbb3025c0 to your computer and use it in GitHub Desktop.
;; Finds the row with the least number of conflicts
(define (min-conflict-row board cx)
(min-conflict-row-r board cx 0 (+ (vector-length board) 1) 9))
(define (min-conflict-row-r board cx cy mini row-conflicts)
(cond
[(>= cy (vector-length board))
(vector-ref row-conflicts mini)]
[(<
(begin
(define new-board (vector-copy board))
(vector-set! new-board cx cy)
(vector-set!
row-conflicts
cy
(vector-ref
(gen-conflicts-test new-board (make-vector (vector-length board) 0) cx 0 0) cx))
(vector-ref row-conflicts cy))
(vector-ref row-conflicts mini))
(min-conflict-row-r board cx (+ cy 1) row-conflicts)]
[else
(min-conflict-row-r board cx (+ cy 1) mini row-conflicts)]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment