blob: 7d75c0949457260e41b507d6ba00e2f1336a6c8c (
plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
;; -*- compile-command: "guile -L . rr-test.scm"; -*-
(use-modules (srfi srfi-64)
(rr))
(test-begin "harness")
(test-equal "friendship 1"
'(1 . 2019)
(return-friendship-pair 1))
(test-equal "friendship 1596"
'(1596 . 424)
(return-friendship-pair 1596))
(test-equal "small report"
'((0 . 2020)
(1 . 2019)
(2 . 2018)
(3 . 2017)
(4 . 2016)
(5 . 2015))
(report->pairs "0 1 2 3 4 5"))
(test-assert "equivalent pair"
(equivalent-pair?
'(1 . 4)
'((5 . 6)
(1 . 5)
(3 . 7)
(4 . 1)
(6 . 2))))
(test-equal "no equivalent pair"
#f
(equivalent-pair?
'(1 . 4)
'((5 . 6)
(1 . 5)
(3 . 7)
(6 . 2))))
(test-equal "found equivalent pair"
'(1 . 5)
(return-equivalent-pair
'((5 . 6)
(1 . 5)
(3 . 7)
(5 . 1)
(6 . 2))))
(test-error "no equivalent pairs"
#t
(return-equivalent-pair
'((5 . 6)
(1 . 5)
(3 . 7)
(6 . 2))))
(test-equal "multiply pair 1"
8
(multiply-pair (cons 1 8)))
(test-equal "multiply pair 2"
24
(multiply-pair (cons 3 8)))
(test-equal "task-complete 1"
1020099
(rr "1009 237 791 478 1537 1011 1628"))
(test-equal "task-complete 2"
514579
(rr "1721
979
366
299
675
1456
"))
(test-end "harness")
|