(ns adventofcode2019.core
- [:require (adventofcode2019 day01 day02 day03
- day04 day05 day06
- day07 day08 day09)])
+ [:require (adventofcode2019 day01 day02 day03 day04
+ day05 day06 day07 day08
+ day09 day10)])
(defn -main
([]
--- /dev/null
+(ns adventofcode2019.day10
+ [:require [adventofcode2019.lib :refer :all]
+ [clojure.string :as str]
+ [clojure.core.match :refer [match]]
+ [clojure.math.combinatorics :as combo]])
+
+(defn day10 []
+ (let [input (get-list-from-file (input-file))
+ to-points (fn [j l]
+ (map-indexed (fn [i m]
+ (if (= \# m) [i j] nil)) l))
+ asteroids (->> input
+ (map-indexed to-points)
+ (reduce concat)
+ (filter some?)
+ (set))
+ to-slope (fn [[a-x a-y] [b-x b-y]]
+ (if (= a-x b-x)
+ :inf
+ (rationalize
+ (/ (- a-y b-y)
+ (- a-x b-x)))))
+ find-visible (fn [ast]
+ (count (set (map (partial to-slope ast)
+ (disj asteroids ast)))))
+ visible-count (map #(vector % (find-visible %)) asteroids)]
+ (part1 (reduce (partial max-key second) visible-count))
+ #_(part2)))