This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-10
Channels
- # adventofcode (99)
- # architecture (10)
- # bangalore-clj (1)
- # beginners (65)
- # boot (9)
- # cider (78)
- # clojure (87)
- # clojure-austin (1)
- # clojure-brasil (13)
- # clojure-dev (14)
- # clojure-gamedev (3)
- # clojure-greece (2)
- # clojure-italy (2)
- # clojure-russia (18)
- # clojure-spec (26)
- # clojure-uk (15)
- # clojurescript (62)
- # core-logic (1)
- # cursive (1)
- # datomic (27)
- # emacs (17)
- # fulcro (2)
- # off-topic (44)
- # onyx (25)
- # perun (139)
- # re-frame (40)
- # reitit (2)
- # ring (4)
- # rum (2)
- # shadow-cljs (1)
- # slack-help (14)
- # unrepl (18)
Yikes, half way through day 3 and I'm sure I'll find a simpler intuitive solution in the other ones.
https://github.com/deepee0086-clj/adventofcode-clojurians/blob/master/src/day_03.clj
It's... definitely a 'walk through by hand' deal. Best I could do was run through their small example step-by-step.
That pretty much describes my code. Amazingly enough, I had the algorithms right the first time. Spent a good deal of time wondering what was wrong before I realized I was using the wrong hash length.
Moar yak shaving for the 'twist' logic, I feel a lot better about it now. Found the right abstraction for the job.
Today was fun! I managed to reuse my functions from part 1 without having to rewrite them at all. https://github.com/orestis/adventofcode/blob/master/clojure/aoc/src/aoc/2017_day10.clj
@fellshard Nice solution! I like your twist
logic; I went with a transient vector instead.
Thanks @grzm — I picked it up somewhere. These days I don’t even read the puzzle on the browser any more, I just copy paste directly in the editor. I love how cider enables me to write tiny functions one by one.
I’m sure there is a way of doing this better, literate programming? Perhaps some kind of jupyter notebook?
I would like to look into devcards to make the whole thing interactive and shareable.
Looks like there's a smaller set of inputs for Day 10. @borkdude and I have the same one.
AFAIK, there’s only 10-20 inputs per puzzle, as the have to all be validated beforehand.
AFAIK, there’s only 10-20 inputs per puzzle, as they have to all be validated beforehand.
@orestis devcards isn’t that more for showing UI components? you could also try klipse, so anyone could play with it in the browser
Okay: the test examples they give require "%02x"
as some of the xor'd values are less than 16. That's not the case for the actual input.
https://github.com/bhauman/advent-of-clojure-2016/blob/master/src/advent_of_clojure_2017/day10.clj
@orestis I found a big optimization if you mod the drop pos here: https://github.com/orestis/adventofcode/blob/master/clojure/aoc/src/aoc/2017_day10.clj#L44
Is (let [[head & tail] s])
the idiomatic way to do (let [head (first s) tail (rest s)])
when you know you deal with vectors?
but pos could be larger than your vector so you can mod it by the length to get the same value
@orestis btw I'm pretty sure [head & tail]
compiles into first
rest
so they should be equivalent and its pretty idiomatic to use [head & tail]
when iterating
Good to know; coming from Elixir where there is some nice syntactic sugar to work with linked lists, I’ve missed that a bit.
I first had a solution with cycle, drop and take, but then decided I could do better with one pass
My day 10: https://github.com/mfikes/advent-of-code/blob/master/src/advent_2017/day_10.cljc
What's up with that strange length sequence 3, 4, 1, 5, 17, 31, 73, 47, 23
and skip size 4
in the running example? That tripped me up for a long time.
Good thinking on just mapping the indices instead of mapping the values in-place, @borkdude
@orestis - Maybe you'd enjoy poking http://gdeer81.github.io/marginalia/
Just solved Day 10. I think it's interesting how my solutions per day all look so similar. Maybe it's just me
I'm still curious. Was this just me missing something fundamental, or did others find this a problem. If you know why it is correct, please share. https://clojurians.slack.com/archives/C0GLTDB2T/p1512927092000137
This is my understanding, thinking out loud: the 3, 4, 1, 5
are from the initial lengths in Part 1. The 17, 31, 73, 47, 23
is the "coda" as .@orestis (edited from @fellshard) named it, which is added in Part 2. A the end of the first part, skip was 4 and position is 4. They're picking up where that left off. Am I following you so far?
That makes complete sense. Wow, them hopping back to part 1, after having started a new example involving 49,44,50,44,51,17,31,73,47,23
really threw me off. Attempting to understand that sequence was an order of magnitude harder than just solving the problem. (Or infinitely harder for me, since it escaped my ability to comprehend it.)
Yeah, I'm not sure why they didn't just continue with the ascii-values they already had in part 2.
Actually, they didn't want to redo the whole thing: they wanted to show an example of maintaining state across rounds.
'coda' was someone else's name, but I like it better than 'suffix', which the problem statement used. The problem writing was a bit disorganized and verbose today; perhaps intentionally, perhaps not. Easy to miss the piece about the suffix, as it's not highlighted or mentioned elsewhere.
Yeah, generally the problems are very high quality, and day 10 was also a high quality problem. Perhaps the description wasn't as clearly written as some of the previous ones. That's cool—it adds to the challenge.
It's why l like AoC - it mimics real world problems a bit better, both with the explanation sometimes being unclear, yet testable with examples; and with two-part solutions, that force you to refactor or remodeling your solution in many cases. A much more interesting learning experience.