-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgflavio a 3 (lento).scm
40 lines (34 loc) · 1001 Bytes
/
gflavio a 3 (lento).scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(define new-round-table ; val: configurazioni
(lambda (n) ; n: interi
(subrange 1 n)
))
(define subrange ; val: lista
(lambda (n k) ; n,k: interi
(if (> n k)
null
(append (list n) (subrange (+ n 1) k)))
))
(define two-serving-knights-in ; val: lista
(lambda (tab) ; tab: tavole-rotonde
(cons (car tab) (list (cadr tab)))
))
(define after-next-exit-from ; val: configurazioni
(lambda (tab) ; tab: tavole-rotonde
(append
(cdddr tab)
(cons (car tab) (list (cadr tab))))
))
(define count ; val: tavole-rotonde
(lambda (tab) ; tab: tavole-rotonde
(if (last-knights-in? tab)
tab
(count (after-next-exit-from tab)))
))
(define last-knights-in? ;val: booleano
(lambda (tab) ;tab: tavola-rotonda
(null? (cddr tab))
))
(define gflavio ; val: etichetta
(lambda (n) ; n: interi
(two-serving-knights-in (count (new-round-table n)))
))