-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathday02_simplest.clj
32 lines (29 loc) · 1.02 KB
/
day02_simplest.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(ns advent-2022-clojure.day02-simplest
(:require [clojure.string :as str]))
(def rock 1)
(def paper 2)
(def scissors 3)
(def loss 0)
(def draw 3)
(def win 6)
(def part1-points {"A X" (+ rock draw)
"A Y" (+ paper win)
"A Z" (+ scissors loss)
"B X" (+ rock loss)
"B Y" (+ paper draw)
"B Z" (+ scissors win)
"C X" (+ rock win)
"C Y" (+ paper loss)
"C Z" (+ scissors draw)})
(def part2-points {"A X" (+ scissors loss)
"A Y" (+ rock draw)
"A Z" (+ paper win)
"B X" (+ rock loss)
"B Y" (+ paper draw)
"B Z" (+ scissors win)
"C X" (+ paper loss)
"C Y" (+ scissors draw)
"C Z" (+ rock win)})
(defn solve [f input] (transduce (map f) + (str/split-lines input)))
(def part1 (partial solve part1-points))
(def part2 (partial solve part2-points))