aboutsummaryrefslogtreecommitdiff
path: root/Semestr 2/racket/l14z22/solution.bak
diff options
context:
space:
mode:
Diffstat (limited to 'Semestr 2/racket/l14z22/solution.bak')
-rw-r--r--Semestr 2/racket/l14z22/solution.bak70
1 files changed, 0 insertions, 70 deletions
diff --git a/Semestr 2/racket/l14z22/solution.bak b/Semestr 2/racket/l14z22/solution.bak
deleted file mode 100644
index 0d4f164..0000000
--- a/Semestr 2/racket/l14z22/solution.bak
+++ /dev/null
@@ -1,70 +0,0 @@
-#lang racket
-
-(require racklog)
-
-(provide solve)
-
-;; transpozycja tablicy zakodowanej jako lista list
-(define (transpose xss)
- (cond [(null? xss) xss]
- ((null? (car xss)) (transpose (cdr xss)))
- [else (cons (map car xss)
- (transpose (map cdr xss)))]))
-
-;; procedura pomocnicza
-;; tworzy listę n-elementową zawierającą wyniki n-krotnego
-;; wywołania procedury f
-(define (repeat-fn n f)
- (if (eq? 0 n) null
- (cons (f) (repeat-fn (- n 1) f))))
-
-;; tworzy tablicę n na m elementów, zawierającą świeże
-;; zmienne logiczne
-(define (make-rect n m)
- (repeat-fn m (lambda () (repeat-fn n _))))
-
-;; predykat binarny
-;; (%row-ok xs ys) oznacza, że xs opisuje wiersz (lub kolumnę) ys
-(define %row-ok
- (%rel ()
-;; TODO: uzupełnij!
- ))
-
-;; TODO: napisz potrzebne ci pomocnicze predykaty
-
-;; funkcja rozwiązująca zagadkę
-(define (solve rows cols)
- (define board (make-rect (length cols) (length rows)))
- (define tboard (transpose board))
- (define ret (%which (xss)
- (%= xss board)
-;; TODO: uzupełnij!
- ))
- (and ret (cdar ret)))
-
-;; testy
-(equal? (solve '((2) (1) (1)) '((1 1) (2)))
- '((* *)
- (_ *)
- (* _)))
-
-(equal? (solve '((2) (2 1) (1 1) (2)) '((2) (2 1) (1 1) (2)))
- '((_ * * _)
- (* * _ *)
- (* _ _ *)
- (_ * * _)))
-
-(equal? (solve '((4) (6) (2 2) (2 2) (6) (4) (2) (2) (2))
- '((9) (9) (2 2) (2 2) (4) (4)))
- '((* * * * _ _)
- (* * * * * *)
- (* * _ _ * *)
- (* * _ _ * *)
- (* * * * * *)
- (* * * * _ _)
- (* * _ _ _ _)
- (* * _ _ _ _)
- (* * _ _ _ _)))
-
-;; TODO: możesz dodać własne testy
-