Fork me on GitHub
#adventofcode
<
2016-12-05
>
fellshard06:12:06

Having a devil of a time with today's. I think it comes down to not being familiar / being able to find documentation on how to use arrays / byte arrays in Clojure.

spfeiffer07:12:36

Scroll down to โ€žArraysโ€œ. Keep in mind they are mutable. That bite me in on of last years challenges.

fellshard07:12:25

In the end, it was mostly the array operations that were aggravating.

fellshard07:12:24

Er, byte operations, that is

fellshard07:12:37

This problem works at the byte level, not the nibble level. So gotta do a little tinkering to get it working efficiently enough to search such a wide space.

abarylko07:12:46

Just finished day 5

abarylko07:12:56

Though didn't use byte arrays....

fellshard07:12:01

Have the resulting code posted anywhere for comparison?

fellshard07:12:50

I've been pushing the raw 'just get an answer' code, then going back and refactoring to see what could be done better, etc.

fellshard07:12:22

Given how painful it is to calculate these hashes, good time to learn this: is there a 'best method' to cache the resolved portions of an infinite sequence?

abarylko08:12:49

good idea on the cache .....

abarylko08:12:02

any reviews and comments are welcome

fellshard08:12:42

Ahh, there's a digest lib?

fellshard08:12:16

Okay, the source I found for MD5 digest did the same thing as the library. Internally, it's using the same thing

fellshard08:12:14

I found that by short-circuiting that library's use of byte hash -> BigInteger -> string every time, there was at least a bit of time savings. Might have to profile and measure it later, but I was reaching for straws trying to get a feedback loop going even with the sample data.

fellshard08:12:51

But may have been more pain than it's worth. ๐Ÿ™‚ I mostly used it to filter the initial results so I only generated string reps when I knew those first five nybbles were 0'd out.

fellshard09:12:08

In the end, it was by far not the MD5 that was the time constraint, it was me being really really bad about mixing eager and lazy ๐Ÿ™‚

fellshard09:12:20

It does take some time to find all the matches - a couple minutes for my second round, since it has to find over 20 valid hashes until it found its position 3 entry, but that's just compounding the problem

fellshard10:12:16

Lots of learning tonight ๐Ÿ˜„

fellshard10:12:53

In the end, I did a refactor 'for the fun of it'. Using the swiss arrows library allowed me to A. reuse the initial part of the calculation, and B. run part A and part B pipelines in parallel

fellshard10:12:11

The parallel furcula is magic

fellshard17:12:07

Glad I finally found an excuse to try that lib ๐Ÿ˜›

andrew.sinclair17:12:06

Hello, @abarylko told me this is the best place to improve my Clojure! I'm looking forward to solve some AoC with some fellow Clojurians. I have lots to learn ๐Ÿ˜‰

fellshard18:12:29

4clojure may be a bit better for basic learning, but last year's AoC challenges are probably great, too ๐Ÿ™‚

fellshard18:12:59

This year's AoC challenges are starting a bit higher level if I recall last year's problems correctly.

andrew.sinclair18:12:40

Yep, I did last years AoC with Clojure. 4clojure was where I cut my teeth.

andrew.sinclair18:12:07

I'd consider myself competent, but I want to go from "hobby language" to "professional understanding" in Clojure.

fellshard18:12:48

Then this is a fantastic place for it. All the problems have two parts, and usually the second part requires you to change your model or refactor your first solution in some way. Very cleverly written.

fellshard18:12:15

And if you aim for the leaderboards, it's an extra bit of challenge ๐Ÿ˜„

spfeiffer19:12:57

I am still stuck around problem 20 of last years AoC because i am a hobbyist and i am lacking free time. I expect to finish this years AoC around 2021 โ˜บ๏ธ

spfeiffer19:12:23

These are the most fun programming exercises i stumbled upon everโ€ฆ

spfeiffer19:12:51

Hearing this years challenges are much harder frightens me โ˜บ๏ธ

mnespor19:12:18

I hope he doesn't throw anything harder than last year's problem 19 at us

fellshard21:12:31

I'm at 14 from last year, 'cuz of free time too...