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.
Scroll down to βArraysβ. Keep in mind they are mutable. That bite me in on of last years challenges.
In the end, it was mostly the array operations that were aggravating.
Er, byte operations, that is
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.
Just finished day 5
Though didn't use byte arrays....
Have the resulting code posted anywhere for comparison?
I've been pushing the raw 'just get an answer' code, then going back and refactoring to see what could be done better, etc.
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?
good idea on the cache .....
my code is here https://github.com/amirci/aoc_clj
any reviews and comments are welcome
Ahh, there's a digest lib?
Okay, the source I found for MD5 digest did the same thing as the library. Internally, it's using the same thing
cool
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.
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.
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 π
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
Lots of learning tonight π
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
The parallel furcula is magic
@fellshard pretty cool!
Glad I finally found an excuse to try that lib π
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 π
4clojure may be a bit better for basic learning, but last year's AoC challenges are probably great, too π
This year's AoC challenges are starting a bit higher level if I recall last year's problems correctly.
Yep, I did last years AoC with Clojure. 4clojure was where I cut my teeth.
I'd consider myself competent, but I want to go from "hobby language" to "professional understanding" in Clojure.
π
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.
And if you aim for the leaderboards, it's an extra bit of challenge π
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 βΊοΈ
These are the most fun programming exercises i stumbled upon everβ¦
Hearing this years challenges are much harder frightens me βΊοΈ
I hope he doesn't throw anything harder than last year's problem 19 at us
π
I'm at 14 from last year, 'cuz of free time too...