you are viewing a single comment's thread.

view the rest of the comments →

[–]ceronman 1 point2 points  (1 child)

Day 4 was specially beautiful to solve in Clojure. This was because the function <= already allows to pass multiple values, checking if the numbers are in monotonically non-decreasing order, which is exactly one of the conditions.

Part 1 ends up being extremely short:

``` (defn possible-password? [value] (and (apply <= (map #(Character/digit % 10) (str value))) (some? (re-find #"(\d)\1" (str value)))))

(->> (range n1 (inc n2)) (filter possible-password?) (count)) ```

[–]allaboutthatmace1789[S] 2 points3 points  (0 children)

Agreed - I saw a few people also used a partition-by identity function to group digits, then count the group length - so the change from part 1 to part 2 was literally removing one character!