blob: 59c6bfeab1e4129d9676f8e087daad6a8b5d8725 (
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
|
;; -*- compile-command: "guile -L . cc-test.scm"; -*-
(use-modules (srfi srfi-64)
(cc))
(test-begin "harness")
(test-equal "Find largest 1 of 1"
10000
(sum-largest-n '(10000) 1))
(test-equal "Find largest 1 of 2"
10001
(sum-largest-n '(10001 6000) 1))
(test-equal "Find largest 1 of 2 requires sort"
10002
(sum-largest-n '(6000 10002) 1))
(test-equal "Find largest 2 of 4 requires sort"
30000
(sum-largest-n '(6000 10000 20000 100) 2))
(test-equal "No empty line to split"
'("Newlines\nmust be doubled!")
(split-on-empty-line "Newlines\nmust be doubled!"))
(test-equal "Empty line split"
'("Through" "the middle!")
(split-on-empty-line "Through\n\nthe middle!"))
(test-equal "Sum one number"
10000
(sum-grouped-string "10000"))
(test-equal "Sum two numbers"
10100
(sum-grouped-string "10000\n100"))
(test-equal "Single second group less"
10000
(cc "10000\n\n500" 1))
(test-equal "Single second group more"
10000
(cc "500\n\n10000" 1))
(test-equal "Add single group greater than second group"
10500
(cc "10000\n500\n\n10300" 1))
(test-equal "Add single group less than second group"
10700
(cc "10000\n500\n\n10700" 1))
(test-equal "Example puzzle input"
24000
(cc "1000\n2000\n3000\n\n4000\n\n5000\n6000\n\n7000\n8000\n9000\n\n10000" 1))
(test-end "harness")
|