Fork me on GitHub
#adventofcode
<
2017-12-29
>
mfikes01:12:34

@bhauman I needed a reducible tree-seq for Planck (to avoid head-holding in its file-seq implementation), and came up with this

(defn reducible-tree-seq
  [branch? children root]
  (eduction
    (take-while seq)
    (map first)
    (iterate (fn [[node & queue]]
               (cond-> queue
                 (branch? node) (into (reverse (children node)))))
      [root])))
Dropping it into your day 24 solution (replacing tree-seq with reducible-tree-seq) appears to drop the runtime in half (probably simply because it is not lazy). I also tried a variant
(transduce (map #(nth % 2)) max 0
  (reducible-tree-seq branch? children [index 0 0 0]))
with similar results. Strictly speaking, since it returns an eduction, it doesn’t directly implement the reducing protocols, but if you feed it to transduce you effectively get what you want.

bhauman03:12:09

@mfikes very cool and super interesting how simple the implementation is

borkdude10:12:59

Has anyone though of doing adventofcode directly in emacs using elisp + a text buffer? 😉

mfikes15:12:05

I got Shenzhen I/O and am playing it with my son. It's a pretty good game (teaching him assembly without him really realizing it.) 🙂

orestis17:12:58

I blogged about my experience with Clojure and Advent of Code: https://orestis.gr/25-days-of-clojure/

spfeiffer19:12:49

I would be very interested in the spacemacs/CIDER demo video. I like spacemacs, but i am not yet into REPL-driven development.

ihabunek19:12:17

me too, i'm using the repl but i have a feeling i'm missing out on a lot of the experience

bhauman18:12:22

posted to Hacker News

borkdude19:12:46

@orestis Thanks for the writeup. What did you mean with apropos-like functionality? I suppose you didn’t mean clojure.core/apropos?

orestis23:12:33

I mean similar to the apropos Linux command where you search a command by your intention, and you get a list of suggestions.