feat: files for day 2
This commit is contained in:
parent
5ba3b822e1
commit
138f379a40
8
main.clj
8
main.clj
@ -1,12 +1,16 @@
|
|||||||
(ns main
|
(ns main
|
||||||
"Advent Of Code 2023 solved in Clojure"
|
"Advent Of Code 2023 solved in Clojure"
|
||||||
(:require
|
(:require
|
||||||
[day01]))
|
[day01]
|
||||||
|
[day02]))
|
||||||
|
|
||||||
(defn aoc-23 []
|
(defn aoc-23 []
|
||||||
(printf "Advent of Code 2023, solved in Clojure.\n\n")
|
(printf "Advent of Code 2023, solved in Clojure.\n\n")
|
||||||
(println (str "Day 01 part 1: " (day01/part1)))
|
(println (str "Day 01 part 1: " (day01/part1)))
|
||||||
(println (str "Day 01 part 2: " (day01/part2))))
|
(println (str "Day 01 part 2: " (day01/part2)))
|
||||||
|
(println (str "Day 02 part 1: " (day02/part1)))
|
||||||
|
(println (str "Day 02 part 2: " (day02/part2)))
|
||||||
|
(println "the end."))
|
||||||
|
|
||||||
(aoc-23)
|
(aoc-23)
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
(def contents (utils/read-file "01" false))
|
(def contents (utils/read-file "01" false))
|
||||||
|
|
||||||
; Vector of String
|
; Vector of String
|
||||||
(def lines "Vector of String" (clojure.string/split-lines contents))
|
(def lines ":: Vector of String" (clojure.string/split-lines contents))
|
||||||
|
|
||||||
; Char -> Bool
|
; Char -> Bool
|
||||||
(defn is-digit? [c]
|
(defn is-digit? [c]
|
||||||
@ -74,7 +74,7 @@
|
|||||||
|
|
||||||
; tests every character on every number
|
; tests every character on every number
|
||||||
(defn sanitize-2
|
(defn sanitize-2
|
||||||
"String -> String"
|
":: String -> String"
|
||||||
[input] (reduce (fn [acc str-pos]
|
[input] (reduce (fn [acc str-pos]
|
||||||
; find which, if any, of the patterns matches on this pos
|
; find which, if any, of the patterns matches on this pos
|
||||||
; match :: Maybe (String String)
|
; match :: Maybe (String String)
|
||||||
|
19
src/day02.clj
Normal file
19
src/day02.clj
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
(ns day02
|
||||||
|
"Day 02 funtions"
|
||||||
|
(:require
|
||||||
|
[utils]
|
||||||
|
[clojure.string]))
|
||||||
|
|
||||||
|
(def contents ":: String" (utils/read-file "01" false))
|
||||||
|
(def lines ":: Vector of String" (clojure.string/split-lines contents))
|
||||||
|
|
||||||
|
(defn part1
|
||||||
|
":: () -> String"
|
||||||
|
[]
|
||||||
|
"")
|
||||||
|
|
||||||
|
(defn part2
|
||||||
|
":: () -> String"
|
||||||
|
[]
|
||||||
|
"")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user