Created
December 1, 2021 07:41
-
-
Save KennyMonster/13e052082fe8a56dff14069a15c842ee to your computer and use it in GitHub Desktop.
AOC 2021 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 day1 | |
(:require [clojure.string :as str])) | |
(def numbers (->> (slurp "input/day-1-input") | |
(str/split-lines) | |
(map #(Integer/parseInt %)))) | |
(defn part-1 [numbers] | |
(->> (map compare (rest numbers) numbers) | |
(filter pos?) | |
(count))) | |
(defn part-2 [numbers] | |
(->> (partition 3 1 numbers) | |
(map #(apply + %)) | |
(part-1))) | |
(comment | |
(part-1 numbers) | |
(part-2 numbers)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment