aboutsummaryrefslogtreecommitdiff
path: root/advent-of-code/2023/02/2.rkt
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2024-02-20 00:42:16 +0800
committerMistivia <i@mistivia.com>2024-02-20 00:42:16 +0800
commitbebb8946d29069b2acb10db71c8c9203ed4ae922 (patch)
tree66ee2e321cbb413baaf32661195f2c734546eba0 /advent-of-code/2023/02/2.rkt
parent3a4e5447a79096d813cdaf4498b9a1e2c086b7ff (diff)
λ looks cool & format code
Diffstat (limited to 'advent-of-code/2023/02/2.rkt')
-rw-r--r--advent-of-code/2023/02/2.rkt26
1 files changed, 13 insertions, 13 deletions
diff --git a/advent-of-code/2023/02/2.rkt b/advent-of-code/2023/02/2.rkt
index 87599d7..7da2cd2 100644
--- a/advent-of-code/2023/02/2.rkt
+++ b/advent-of-code/2023/02/2.rkt
@@ -18,21 +18,21 @@
(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 (power game)