https://github.com/ryanfleck/aoc24
Advent of Code 2024 - Clojure solutions.
https://github.com/ryanfleck/aoc24
advent-of-code-2024 clojure
Last synced: 7 months ago
JSON representation
Advent of Code 2024 - Clojure solutions.
- Host: GitHub
- URL: https://github.com/ryanfleck/aoc24
- Owner: RyanFleck
- License: other
- Created: 2024-12-02T23:03:40.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-05T02:37:08.000Z (about 1 year ago)
- Last Synced: 2025-02-01T08:25:41.342Z (12 months ago)
- Topics: advent-of-code-2024, clojure
- Language: Clojure
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Advent of Code 2024
[](https://github.com/RyanFleck/aoc24/actions/workflows/clojure.yml)
[](https://codecov.io/github/RyanFleck/aoc24)
This year I am taking on the challenges in **Clojure**.
To use, add a `profiles.clj` file with the following data:
```clojure
{:dev {:env {:aoc-session "53616c7... "}}}
```
You'll need to step through and execute (`C-x C-e`) most of the
solutions step by step with a REPL.
```clojure
(comment
(= 2 (count-trues (map is-level-safe? (str->matrix sample)))) ; test case
(count-trues (map is-level-safe? (str->matrix input)))) ; correct!
```
## Solutions
- [Day 1](https://github.com/RyanFleck/aoc24/blob/master/src/aoc24/day1.clj)
- [Day 2](https://github.com/RyanFleck/aoc24/blob/master/src/aoc24/day2.clj)
- [Day 3](https://github.com/RyanFleck/aoc24/blob/master/src/aoc24/day3.clj)
```clojure
(->>
(s/split day-3-input #"do")
(filter #(not (s/starts-with? % "n't")))
(apply str)
(re-seq #"mul\((\d+),(\d+)\)")
(map #(* (str->int (nth % 1)) (str->int (nth % 2))))
(apply +)) ; correct!
```
- [Day 4](https://github.com/RyanFleck/aoc24/blob/master/src/aoc24/day4.clj) (just part one)
```clojure
(defn day-4-answer [input]
(let [rows (get-rows input)
cols (get-columns input)
diag-se (get-diagonal-rows-se input)
diag-sw (get-diagonal-rows-sw input)
combined (flatten (apply merge rows cols diag-se diag-sw))
reversed (map #(apply str (reverse %)) combined)
all (flatten (apply merge combined reversed))]
(count (re-seq #"XMAS" (s/join "-" all)))))
```
- [Day 5](https://github.com/RyanFleck/aoc24/blob/master/src/aoc24/day5.clj)
## License
Copyright © 2024 Ryan Fleck
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the Eclipse
Public License, v. 2.0 are satisfied: GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or (at your
option) any later version, with the GNU Classpath Exception which is available
at https://www.gnu.org/software/classpath/license.html.
## Code Coverage
Unit tests aren't critical to this project, but visualizations are still cool:
