Created
July 27, 2023 21:40
-
-
Save hovsater/b3c8bb0774a4f2a1c364c635027a631b to your computer and use it in GitHub Desktop.
Solution to Advent of Code year 2022, day 1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns advent-of-code-year-2022.day-01 | |
"Advent of Code - Solution to year 2022, day 1." | |
(:require | |
[clojure.string :as str])) | |
(def sample-input | |
"1000 | |
2000 | |
3000 | |
4000 | |
5000 | |
6000 | |
7000 | |
8000 | |
9000 | |
10000") | |
(def input (slurp "./input/year_2022/day_01.txt")) | |
(defn parse-input [s] | |
(->> | |
(str/split s #"\n\n") | |
(map #(->> (str/split % #"\n") (map parse-long) (reduce +))))) | |
(defn part-1 [input] | |
(->> (parse-input input) (sort >) first)) | |
(defn part-2 [input] | |
(->> (parse-input input) (sort >) (take 3) (reduce +))) | |
(part-1 input) | |
(part-2 input) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment