Fork me on GitHub
#adventofcode
<
2017-12-10
>
theeternalpulse06:12:54

Yikes, half way through day 3 and I'm sure I'll find a simpler intuitive solution in the other ones.

fellshard06:12:50

Hmm. My soln. for today's part two matches the example inputs, but not my own.

fellshard06:12:48

Ooooh. Bad hex formatting, I think.

grzm06:12:37

I'm glad my solution worked, because I don't know how I would have debugged that.

fellshard06:12:04

It's... definitely a 'walk through by hand' deal. Best I could do was run through their small example step-by-step.

grzm06:12:49

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.

grzm06:12:14

Now trying to port it to cljs

grzm06:12:31

Pushed. Now to sleep!

fellshard07:12:00

Moar yak shaving for the 'twist' logic, I feel a lot better about it now. Found the right abstraction for the job.

orestis10:12:16

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

orestis10:12:50

@fellshard Nice solution! I like your twist logic; I went with a transient vector instead.

borkdude12:12:24

1.3 ms for part 1, 224ms for part 2

nooga13:12:47

here’s mine

nooga13:12:39

3.9ms / 224,8ms

grzm15:12:51

@orestis nice mix of code, tests, and description

orestis15:12:36

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.

orestis15:12:31

I’m sure there is a way of doing this better, literate programming? Perhaps some kind of jupyter notebook?

grzm15:12:58

I'm much more pragmatic about it: you've got a solution that works really well.

orestis15:12:06

I would like to look into devcards to make the whole thing interactive and shareable.

grzm15:12:32

Looks like there's a smaller set of inputs for Day 10. @borkdude and I have the same one.

orestis15:12:34

AFAIK, there’s only 10-20 inputs per puzzle, as the have to all be validated beforehand.

orestis15:12:53

AFAIK, there’s only 10-20 inputs per puzzle, as they have to all be validated beforehand.

grzm15:12:46

makes sense

borkdude15:12:25

@orestis devcards isn’t that more for showing UI components? you could also try klipse, so anyone could play with it in the browser

grzm15:12:24

@borkdude: how does yours work with using "%x" for formatting? I needed to use "%02x"

grzm15:12:04

I've run yours locally and confirmed it works.

orestis15:12:14

Ah, yes, I haven’t used either so got them mixed up.

borkdude15:12:55

@grzm don’t know, haven’t thought about it deeply

grzm15:12:33

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.

borkdude15:12:47

thanks, I’ll enhance

bhauman16:12:27

60ms on part 2 🙂

bhauman16:12:43

but it wasn't easy

bhauman16:12:03

found some weird things: like apply is faster than arg destructuring

bhauman16:12:57

in my first version, part 2 never finished as I got tired of waiting after 5 minutes

bhauman16:12:14

@orestis our answers are so similar 🙂

orestis16:12:41

Is (let [[head & tail] s]) the idiomatic way to do (let [head (first s) tail (rest s)]) when you know you deal with vectors?

bhauman16:12:15

I wouldn't say so

orestis16:12:26

@bhauman You mean by skipping the cycle?

bhauman16:12:01

you keep the cycle

bhauman16:12:35

but pos could be larger than your vector so you can mod it by the length to get the same value

bhauman16:12:50

so less iterating through the array

bhauman16:12:23

(= (drop (mod pos (count x)) (cycle x)) (drop pos (cycle x)))

orestis16:12:56

Hm - I think I mod the pos anyway at every step so it should be equivalent?

bhauman16:12:11

oh ok missed that 🙂

bhauman16:12:49

well that makes much more sense

bhauman16:12:13

i should have done that

bhauman16:12:28

@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

bhauman16:12:41

over any collection

orestis16:12:33

Good to know; coming from Elixir where there is some nice syntactic sugar to work with linked lists, I’ve missed that a bit.

borkdude16:12:10

I first had a solution with cycle, drop and take, but then decided I could do better with one pass

borkdude16:12:36

I could probably make it faster with transients, but I haven’t used any today

bhauman16:12:12

@borkdude your solution gets a 👍 for clarity and simplicity

bhauman16:12:14

and its way fast enough to get the job done

borkdude16:12:16

thanks 🙂

bhauman16:12:14

@nooga your hurting my brain 🙂 trying to follow it ... trying ...

nooga16:12:25

sorry 😄

nooga16:12:32

definately not a production code 😄

bhauman16:12:13

(c-splice a p (reverse (c-slice a p l))) for the win

borkdude16:12:14

it looks like C written in Clojure 🙂

bhauman16:12:01

I see a p l and I see APL

nooga16:12:04

I get into this mode sometimes 😄

borkdude16:12:28

p0, ah, of course, a pointer

borkdude16:12:38

and then some bit shifting going on

nooga16:12:49

I wrote this while reading the puzzle, not after

nooga16:12:49

there’s not much conscious thought into this 😄

mfikes17:12:32

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.

bhauman17:12:48

oh you can mod the skip size!!

borkdude17:12:19

@mfikes nice concise solution

fellshard18:12:54

Good thinking on just mapping the indices instead of mapping the values in-place, @borkdude

fellshard18:12:13

Less list-shifting shenanigans that way

orestis19:12:59

Ohh that seems nice! I’ll give it a proper look.

nooga19:12:43

@mfikes I think it’s bascially what I did but mine is less clear

jmb22:12:42

Just solved Day 10. I think it's interesting how my solutions per day all look so similar. Maybe it's just me

mfikes23:12:07

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

grzm23:12:22

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?

mfikes23:12:56

@grzm Thank-you. That helps! (WTF!)

mfikes23:12:16

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.)

grzm23:12:07

Yeah, I'm not sure why they didn't just continue with the ascii-values they already had in part 2.

mfikes23:12:41

I was trying desperately to derive 3, 4, 1, 5 from something in part 2.

grzm23:12:51

Actually, they didn't want to redo the whole thing: they wanted to show an example of maintaining state across rounds.

grzm23:12:27

Well, part of the real world is interpreting requirements, right? 😉

mfikes23:12:35

Cool. Thanks. "Mike, look at part 1," was all I needed 🙂

mfikes23:12:54

Indeed, that is part of problem solving. Requirements interpretation.

grzm23:12:27

Well, the rest of it was me making sure I understood the question

fellshard23:12:34

'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.

grzm23:12:29

Right, it was .@orestis

mfikes23:12:22

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.

fellshard23:12:26

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.