aboutsummaryrefslogtreecommitdiff
path: root/advent-of-code/2022/02/2.rkt
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2024-02-24 23:07:57 +0800
committerMistivia <i@mistivia.com>2024-02-24 23:12:21 +0800
commitfc4ec74e50ba362af054dca79d79dd4b7853ea5b (patch)
treeb3c54344bc99d53d3040869e9ee80c3184e16ade /advent-of-code/2022/02/2.rkt
parent5898fa29a56f699bebb4644188348840b26207d9 (diff)
reformat code
Diffstat (limited to 'advent-of-code/2022/02/2.rkt')
-rw-r--r--advent-of-code/2022/02/2.rkt45
1 files changed, 0 insertions, 45 deletions
diff --git a/advent-of-code/2022/02/2.rkt b/advent-of-code/2022/02/2.rkt
deleted file mode 100644
index 608d8aa..0000000
--- a/advent-of-code/2022/02/2.rkt
+++ /dev/null
@@ -1,45 +0,0 @@
-#lang racket
-
-(require "../../lib/utils.rkt")
-
-(define lines
- (call-with-input-file "input"
- (λ (fp) (get-lines fp))))
-
-(define games (map string-split lines))
-
-(define (transform-cheat mine oppo)
- (cond ((string=? "X" mine) (cond ((string=? "A" oppo) "Z")
- ((string=? "B" oppo) "X")
- ((string=? "C" oppo) "Y")))
- ((string=? "Y" mine) (cond ((string=? "A" oppo) "X")
- ((string=? "B" oppo) "Y")
- ((string=? "C" oppo) "Z")))
- ((string=? "Z" mine) (cond ((string=? "A" oppo) "Y")
- ((string=? "B" oppo) "Z")
- ((string=? "C" oppo) "X")))))
-
-(set! games
- (map
- (λ (x)
- (list (car x) (transform-cheat (cadr x) (car x))))
- games))
-
-(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))))
-
-(apply + (map score games)) \ No newline at end of file