diff options
author | bd <bdunahu@gmail.com> | 2024-06-10 21:03:08 -0600 |
---|---|---|
committer | bd <bdunahu@gmail.com> | 2024-06-10 21:03:08 -0600 |
commit | 5745b2875046d0bbe3bf25f1d03a297b624c55c6 (patch) | |
tree | ad49f7305c4217692c470df14438ef0e4eb4640c /report-repair/rr.scm | |
parent | 116aa074b190599e38a43bd6a8602a05cebdfb5d (diff) |
AoC 2015.4 p1+2
Diffstat (limited to 'report-repair/rr.scm')
-rw-r--r-- | report-repair/rr.scm | 23 |
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)))) |