aboutsummaryrefslogtreecommitdiff
path: root/advent-of-code/2022/02/1.rkt
diff options
context:
space:
mode:
Diffstat (limited to 'advent-of-code/2022/02/1.rkt')
-rw-r--r--advent-of-code/2022/02/1.rkt34
1 files changed, 17 insertions, 17 deletions
diff --git a/advent-of-code/2022/02/1.rkt b/advent-of-code/2022/02/1.rkt
index 35c5a5c..5114c9c 100644
--- a/advent-of-code/2022/02/1.rkt
+++ b/advent-of-code/2022/02/1.rkt
@@ -3,26 +3,26 @@
(require "../../lib/utils.rkt")
(define lines
- (call-with-input-file "input"
- (lambda (fp) (get-lines fp))))
+ (call-with-input-file "input"
+ (λ (fp) (get-lines fp))))
(define games (map string-split lines))
(define (score game)
- (define (base-score mine)
- (cond ((string=? "X" mine) 1)
- ((string=? "Y" mine) 2)
- ((string=? "Z" mine) 3)))
- (define (win-score mine oppo)
- (cond ((string=? "X" mine) (cond ((string=? "A" oppo) 3)
- ((string=? "B" oppo) 0)
- ((string=? "C" oppo) 6)))
- ((string=? "Y" mine) (cond ((string=? "A" oppo) 6)
- ((string=? "B" oppo) 3)
- ((string=? "C" oppo) 0)))
- ((string=? "Z" mine) (cond ((string=? "A" oppo) 0)
- ((string=? "B" oppo) 6)
- ((string=? "C" oppo) 3)))))
- (+ (base-score (cadr game)) (win-score (cadr game) (car game))))
+ (define (base-score mine)
+ (cond ((string=? "X" mine) 1)
+ ((string=? "Y" mine) 2)
+ ((string=? "Z" mine) 3)))
+ (define (win-score mine oppo)
+ (cond ((string=? "X" mine) (cond ((string=? "A" oppo) 3)
+ ((string=? "B" oppo) 0)
+ ((string=? "C" oppo) 6)))
+ ((string=? "Y" mine) (cond ((string=? "A" oppo) 6)
+ ((string=? "B" oppo) 3)
+ ((string=? "C" oppo) 0)))
+ ((string=? "Z" mine) (cond ((string=? "A" oppo) 0)
+ ((string=? "B" oppo) 6)
+ ((string=? "C" oppo) 3)))))
+ (+ (base-score (cadr game)) (win-score (cadr game) (car game))))
(apply + (map score games)) \ No newline at end of file