Permalink
Browse files

43.3.2

  • Loading branch information...
1 parent 2061f25 commit 43c4a99c177fae640933cfbff009a3814bfe1cc3 @falsetru committed Jun 11, 2012
Showing with 45 additions and 1 deletion.
  1. +5 −1 43/43.3.1.scm
  2. +40 −0 43/43.3.2.scm
View
@@ -1,5 +1,9 @@
#lang racket
+(provide
+ board-for-all
+ place-queen)
+
(define (board-for-all f board)
(local ((define N (vector-length board)))
(for-each (lambda (i)
@@ -45,4 +49,4 @@
)
))
-(exit (run-tests place-queen-tests))
+(run-tests place-queen-tests)
View
@@ -0,0 +1,40 @@
+#lang racket
+
+(require "43.3.1.scm")
+
+(define (unplace-queen board i j)
+ (board-for-all
+ (lambda (I J x)
+ (cond [(or (= i I)
+ (= j J)
+ (= (+ i j) (+ I J))
+ (= (- i j) (- I J))) true]
+ [else x]))
+ board))
+
+(require rackunit)
+(require rackunit/text-ui)
+
+(define unplace-queen-tests
+ (test-suite
+ "Test for unplace-queen"
+
+ (test-case
+ ""
+ (define board
+ (build-vector
+ 3
+ (lambda (i)
+ (build-vector
+ 3
+ (lambda (j) false)))))
+ (unplace-queen board 0 0)
+ (check-equal?
+ board
+ '#(#(#t #t #t)
+ #(#t #t #f)
+ #(#t #f #t)))
+ )
+ ))
+
+(exit (run-tests unplace-queen-tests))

0 comments on commit 43c4a99

Please sign in to comment.