(define concat (lambda (a b) (if (null? a) b (cons (car a) (concat (cdr a) b))))) (define inverte (lambda (a) (if (null? a) a (concat (inverte (cdr a)) (cons (car a) '()))))) (define p (lambda (l i) (if (= (length l) 8) (begin (display l) (newline)) (if (<= i 8) (if (testa l i 1) (begin (p (inverte (cons i (inverte l))) 1) (p l (+ i 1))) (p l (+ i 1))))))) (define pode? (lambda (x1 y1 x2 y2) (if (= (+ x1 y1) (+ x2 y2)) #f (if (= (- x1 y1) (- x2 y2)) #f (if (= y1 y2) #f #t))))) (define testa (lambda (l i pos) (if (null? l) #t (if (= (length l) 1) (pode? 1 (car l) (+ pos 1) i) (if (pode? (length l) (car (inverte l)) (+ (length l) pos) i) (testa (inverte (cdr (inverte l))) i (+ pos 1)) #f)))))