Day 86 - Coaching and advent of code challenges
Cleaned up the code from the first days Advent of Code challenge.
Mentoring my friend in the USA who is learning Clojure.
Code from todayλ︎
;; using a set
(require 'clojure.set)
;; if the adjusted frequency is used as an argument to the set,
;; then the set will return the frequency if its already there
;; otherwise the set returns nil
;; so we can then return the adjusted frequency
;; otherwise we keep going
;; Where do two maps intersect, e.g. share the same values
(clojure.set/intersection #{1 2 3} #{3 4 5})
;; => #{3}
;; Define maps for example data
(def a #{1 2 3})
(def b #{3 4 5})
;; Return a set that is the first set without elements of the remaining sets
(clojure.set/difference a b)
;; => #{1 2}
(clojure.set/difference b a)
;; => #{4 5}
;; Concatenate
(concat (clojure.set/difference a b) (clojure.set/difference b a))
;; => (1 2 4 5)
Thank you.