This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-13
Channels
- # adventofcode (77)
- # beginners (132)
- # boot (11)
- # cider (40)
- # clara (10)
- # cljsjs (1)
- # cljsrn (4)
- # clojure (148)
- # clojure-android (1)
- # clojure-greece (5)
- # clojure-italy (5)
- # clojure-nl (7)
- # clojure-spec (57)
- # clojure-uk (9)
- # clojurescript (115)
- # core-matrix (1)
- # cursive (3)
- # data-science (1)
- # datomic (1)
- # duct (7)
- # emacs (20)
- # fulcro (29)
- # funcool (4)
- # graphql (31)
- # instaparse (15)
- # java (1)
- # jobs (6)
- # jobs-discuss (95)
- # leiningen (2)
- # off-topic (30)
- # om (4)
- # onyx (7)
- # pedestal (6)
- # quil (4)
- # re-frame (52)
- # reagent (59)
- # rum (1)
- # spacemacs (3)
- # specter (61)
- # test-check (3)
Nice.. I went from 10ms to 3ms using (and working around) a transient set in the hot loop
I wonder if there’s a nice O(n) solution to part2
I was thinking the same thing, except I'm not sure that gets you the right answer still
It could certainly help you find one point in time at which all the scanners would be at zero at the time your packet arrives, but I'm not sure that would be useful information, nor would it be guaranteed to be the minimum possible result
https://github.com/minikomi/advent-of-code/blob/master/src/advent/2017/day13.clj#L39-L48 here's mine anyway!
OK, this is the first time in AoC 2017 that my fans are spin-spin-spinning and I get no response from second part.
You can see all my progress in the same file: https://github.com/orestis/adventofcode/blob/master/clojure/aoc/src/aoc/2017_day13.clj
@minikomi I think we arrived at the same logic but your version is a bit more “unrolled” than mine.
It Should be: https://github.com/clojure/clojure/blob/clojure-1.9.0-alpha14/src/clj/clojure/core.clj#L2682
Day 13: https://github.com/mfikes/advent-of-code/blob/master/src/advent_2017/day_13.cljc
I wonder if there is an efficient solution to part 2 using some variation of the Chinese remainder theorem.
https://github.com/bhauman/advent-of-clojure-2016/blob/master/src/advent_of_clojure_2017/day13.clj
Interesting. I didn't even think about that aspect. I just wrote it for readability / concision.
our solutions are similar, you moved the logic a step deeper which eliminated the need to pass data around
Well, down from 21 seconds to 900ms for part 2. Now to see what solutions you guys came up with.
@mfikes is there a way you're preventing the github banner thing from displaying when you paste a link? That's really nice and tidy.
@grzm After pasting a link, you’ll see a little delete button next to the GitHub banner.
(defn find-first
[pred vals]
(reduce
(fn [_ v]
(when (pred v)
(reduced v)))
nil
vals))
(time (some identity (repeat 10000000 nil))) ;; 250 ms
(time (find-first identity (repeat 10000000 nil))) ;; 40 ms
(time (some #(when (> ^long % 10000000) %) (range))) ;; 558 ms
(time (find-first #(> ^long % 10000000) (range))) ;; 95 ms
I guess one more reason reduce is faster because many collections know how to reduce themselves
Hello! Im using Advent of Code as a way of learning Clojure and have just created a repo of what I have so far. Thought id post it incase anyone was interested 😃 https://github.com/sandemchad/clj-advent-of-code-2017
@chad Feel free to add yours to this one too: https://github.com/adventofcode-clojurians/adventofcode-clojurians
Thank you 🙂 I am really enjoying using Clojure solving these problems have been a really good way of learning.