summaryrefslogtreecommitdiff
path: root/report-repair/rr.scm
diff options
context:
space:
mode:
Diffstat (limited to 'report-repair/rr.scm')
-rw-r--r--report-repair/rr.scm23
1 files changed, 11 insertions, 12 deletions
diff --git a/report-repair/rr.scm b/report-repair/rr.scm
index 11c4bcd..d96fa20 100644
--- a/report-repair/rr.scm
+++ b/report-repair/rr.scm
@@ -1,20 +1,19 @@
(define-module (rr)
#:use-module (combinations)
#:use-module (srfi srfi-1)
- #:use-module (ice-9 format)
#:use-module (ice-9 exceptions)
#:export (rr
- get-2020-terms
- includes-all?
- generate-sets
- make-complete-set))
+ get-2020-terms
+ includes-all?
+ generate-sets
+ make-complete-set))
(define (rr str len)
(apply * (get-2020-terms (map string->number
- (string-split
- (string-trim-both str char-set:whitespace)
- char-set:whitespace))
- len)))
+ (string-split
+ (string-trim-both str char-set:whitespace)
+ char-set:whitespace))
+ len)))
(define (get-2020-terms lst len)
"Given a list of numbers, returns a list
@@ -24,8 +23,8 @@ Throws input-exception if none are found."
(let loop ((sets (generate-sets lst len)))
(cond
((null? sets) (raise-exception
- (make-exception-with-message
- (format #f "Could not find ~s arguments that add to 2020 in inputs!" len))))
+ (make-exception-with-message
+ (format #f "Could not find ~s arguments that add to 2020 in inputs!" len))))
((includes-all? (car sets) lst) (car sets))
(#t (loop (cdr sets))))))
@@ -33,7 +32,7 @@ Throws input-exception if none are found."
"Returns #t if all elements in LST1
are present in LST2, #f otherwise."
(equal? lst1
- (lset-intersection eqv? lst1 lst2)))
+ (lset-intersection eqv? lst1 lst2)))
(define (generate-sets lst len)
(map make-complete-set (combinations lst (1- len))))