aboutsummaryrefslogtreecommitdiff
path: root/advent-of-code/2023/02/1.rkt
diff options
context:
space:
mode:
Diffstat (limited to 'advent-of-code/2023/02/1.rkt')
-rw-r--r--advent-of-code/2023/02/1.rkt44
1 files changed, 22 insertions, 22 deletions
diff --git a/advent-of-code/2023/02/1.rkt b/advent-of-code/2023/02/1.rkt
index e0a7bf9..500e916 100644
--- a/advent-of-code/2023/02/1.rkt
+++ b/advent-of-code/2023/02/1.rkt
@@ -18,35 +18,35 @@
(define b 0)
(define balls (string-split str ","))
(set! balls
- (map (lambda (s)
- (define pair (map string-trim (string-split s " ")))
- (list (string->number (car pair)) (cadr pair)))
- balls))
+ (map (λ (s)
+ (define pair (map string-trim (string-split s " ")))
+ (list (string->number (car pair)) (cadr pair)))
+ balls))
(let loop ((balls balls))
(if (null? balls)
- '()
- (let ()
- (define ball (car balls))
- (define number (car ball))
- (define color (cadr ball))
- (cond ((string=? "red" color) (set! r number))
- ((string=? "green" color) (set! g number))
- ((string=? "blue" color) (set! b number)))
- (loop (cdr balls)))))
+ '()
+ (let ()
+ (define ball (car balls))
+ (define number (car ball))
+ (define color (cadr ball))
+ (cond ((string=? "red" color) (set! r number))
+ ((string=? "green" color) (set! g number))
+ ((string=? "blue" color) (set! b number)))
+ (loop (cdr balls)))))
(list r g b))
(define (possible? game)
(if (null? game)
- #t
- (let ()
- (define head (car game))
- (if (or (> (car head) 12) ; r
- (> (cadr head) 13) ; g
- (> (caddr head) 14)) ; b
- #f
- (possible? (cdr game))))))
+ #t
+ (let ()
+ (define head (car game))
+ (if (or (> (car head) 12) ; r
+ (> (cadr head) 13) ; g
+ (> (caddr head) 14)) ; b
+ #f
+ (possible? (cdr game))))))
(apply + (map cadr
- (filter (lambda (game)
+ (filter (λ (game)
(possible? (car game)))
(enumerate (map extract-game lines)))))