blob: 3661c64fff4748365592445e8c3181edcb825e54 (
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
|
;; -*- compile-command: "guile -L . rr-test.scm"; -*-
(use-modules (srfi srfi-64)
(rr))
(test-begin "harness")
(test-equal "completed set size 1"
'(1 2019)
(make-complete-set '(2019)))
(test-equal "completed set size 1"
'(366 675 979)
(make-complete-set '(675 979)))
(test-equal "generate sets compatible"
'((675 979 366)
(366 979 675)
(979 366 675))
(generate-sets '(979 366 675) 3))
(test-assert "does not include all"
(not (includes-all? '(1 2 3) '(1 2 4 5 6))))
(test-assert "includes all"
(includes-all? '(1 2 3) '(1 2 3 5 6)))
(test-error "no two inputs add to 2020"
#t
(get-2020-terms '(979 366 675)
2))
(test-error "2020 not present"
#t
(get-2020-terms '(1 2 3)
1))
(test-equal "2020 is present"
'(2020)
(get-2020-terms '(2020 1 2 3)
1))
(test-equal "three elements which add to 2020"
'(675 979 366)
(get-2020-terms '(979 366 675)
3))
(test-error "three elements which do not add to 2020"
#t
(get-2020-terms '(979 365 675)
3))
(test-equal "some two elements add to 2020"
'(299 1721)
(get-2020-terms '(1721 979 366 299 675 1456)
2))
(test-equal "some three elements add to 2020"
'(675 979 366)
(get-2020-terms '(1721 979 366 299 675 1456)
3))
(test-equal "rr wrapper 2"
514579
(rr "1721 979 366 299 675 1456" 2))
(test-equal "rr wrapper 3"
241861950
(rr "1721 979 366 299 675 1456" 3))
(test-end "harness")
|