This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-15
Channels
- # adventofcode (121)
- # bangalore-clj (5)
- # beginners (46)
- # boot-dev (9)
- # cider (20)
- # cljs-dev (7)
- # cljsrn (1)
- # clojure (341)
- # clojure-austin (7)
- # clojure-greece (144)
- # clojure-india (3)
- # clojure-italy (5)
- # clojure-spain (1)
- # clojure-spec (34)
- # clojure-sweden (3)
- # clojure-uk (90)
- # clojurescript (24)
- # core-async (1)
- # core-logic (7)
- # cursive (108)
- # datascript (2)
- # datomic (39)
- # events (1)
- # fulcro (225)
- # graphql (8)
- # hoplon (86)
- # instaparse (12)
- # jobs-discuss (2)
- # jvm (4)
- # keechma (1)
- # lein-figwheel (2)
- # leiningen (12)
- # off-topic (26)
- # onyx (35)
- # other-languages (1)
- # pedestal (3)
- # planck (11)
- # re-frame (12)
- # reagent (12)
- # reitit (5)
- # spacemacs (48)
- # specter (29)
- # sql (2)
- # test-check (1)
- # unrepl (71)
I started trying to read this as a solution to day14 and my brain started to hurt lol.. need more morning coffee
Is it wrong that I as someone who likes coding have an aversion to binary numbers? Two days in a row 😞
I'm getting 7s for first and 5s for 2nd using lazy; ~1s using recursion for first part
https://github.com/minikomi/advent-of-code/blob/master/src/advent/2017/day15.clj#L28 that drop should be on lines 39 and 40
I had the same problem in my code, took me some time to find the problem 😞 (and some attempts typing the wrong answer 8))
first: part1 is also not correct but, there it doesn't matter, because there is no filtering involved, and the start values do not have the same 16 lower bits. Your (and my) code generates 277, (* 277 16807) and so on, but the start value should not be in the generated steps (check with example in problem). For part 2, the modulo 8 and 4 checks allows the start value for input 512 and the pairs are of by 1 for the complete range
oh, i see, i want to drop the first generated value - since they're seeds and not generated, but by having the drop where i had it, it drops the first filterted generated value
Btw, here’s my code: https://github.com/borkdude/aoc2017/blob/master/src/day15.clj I think it could be optimized if I would loop/recurify the ranges as well
day 15 from me: https://github.com/skazhy/advent/blob/master/src/advent/2017/day15.clj currently ~ 18 seconds for 1st / 10 for 2nd.
So… it turns out to be this sequence: https://en.wikipedia.org/wiki/Lehmer_random_number_generator
Hi all! I had to skip yesterday because I was travelling, but I’m now all caught up. Day 14: https://github.com/orestis/adventofcode/blob/master/clojure/aoc/src/aoc/2017_day14.clj Day 15: https://github.com/orestis/adventofcode/blob/master/clojure/aoc/src/aoc/2017_day15.clj
@borkdude looking at your implementation of multiple-of
, what's wrong with (zero? (mod x y))
?
@ihabunek Better example:
boot.user=> (defn inc* [x] (println "inc") (inc x))
#'boot.user/inc*
boot.user=> (defn f [x y] (let [x' (inc* x)] (+ x' y)))
#'boot.user/f
boot.user=> (f 1 1)
inc
3
boot.user=> (def g (partial f 1))
#'boot.user/g
boot.user=> (g 1)
inc
3
In other words: partial does nothing for inlining stuffI wonder if there is a faster way of comparing the lowest 16 bits than (== (unchecked-short ..) (unchecked-short ..))
, maybe something using xor
, or maybe it already does that on a lower level
i think my code is slow because of the way i use sequences more than comparing bits.
@ihabunek evaluate the settings from the comment section at the bottom, then you’ll see warnings about boxing
Terribly sorry for the long output by range… didn’t know it would consume that much estate… pinging an admin who can remove it.
i disovered parinfer for sublime text and don't know how i ever managed to code clojure before that
I’m using Cursive in IntelliJ and it also has parinfer
Although not the latest and greatest version 3
btw here’s my solution for today https://github.com/axelarge/advent-of-code/blob/master/src/advent_of_code/2017/day15.clj
all cleaned up 👼
y’all have fun now - merry conjmas!
xform-mas? 😎
switching between advent of clojure in the morning and python for my actual job is messing with my brain
Nice solution @mikelis.vindavs
https://github.com/bhauman/advent-of-clojure-2016/blob/master/src/advent_of_clojure_2017/day15.clj
I messed around with macros to get it down to around 236 ms for part 1 and 675 ms for part 2.
Ahh cool. I forgot about unchecked-math and boxing. Fixing that results in 165 ms for part 1 and 295 ms for part 2.
@mfikes Am I right that the macro approach only helps for inlining var values, but otherwise doesn’t help very much?
My initial motivation was to inline the arguments. I think you had also mentioned that inlining the 4 and 8 resulted in faster performance than if they were passed as arguments. I was seeing a similar effect. But var inlining is probably another effect. One odd thing I never figured out was that if I macroexpanded the solution to part 1, the cleaned up expansion inexplicably ran slower.