Fork me on GitHub
#clojure-greece
<
2017-12-01
>
greenonion13:12:21

ξεκινησε το advent

greenonion13:12:36

η πρωτη ηταν ευκολη αλλα ωραιο να τη λυνεις με clj

orestis15:12:53

#adventofcode 🙂

greenonion15:12:19

ωραια φαση με τα inline tests @orestis

greenonion15:12:24

εγω το προσεγγισα ετσι

stathissideris16:12:52

@greenonion

(as-> "91212129" $
  (mapv #(Character/getNumericValue %) $)
  (conj $ (first $))
  (partition 2 1 $)
  (remove #(apply not= %) $)
  (map first $)
  (apply + $))

stathissideris16:12:23

gia to 1o star toulaxiston

greenonion19:12:58

Ωραίο κι αυτό

greenonion19:12:08

Κανονικά θέλει transducers όμως :D

apod20:12:04

kai ego tora to ekana plaka eixe, to ekana me alli logiki me reduce kai indexes 😛

apod20:12:38

(defn captcha-solver
  ([s] (captcha-solver s 1))
  ([s step]
   (let [cycled (cycle s)]
     (reduce (fn [acc [i current]]
               (let [next (nth cycled (+ i step))]
                 (if (= next current)
                   (+ acc (Character/getNumericValue current))
                   acc))) 0 (keep-indexed vector s)))))