r/adventofcode • u/daggerdragon • Dec 03 '16
SOLUTION MEGATHREAD --- 2016 Day 3 Solutions ---
--- Day 3: Squares With Three Sides ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).
DECKING THE HALLS WITH BOUGHS OF HOLLY IS MANDATORY [?]
This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.
edit: Leaderboard capped, thread unlocked!
17
Upvotes
View all comments
Show parent comment
2
u/nullmove Dec 06 '16
That makes it two of us who missed the sort trick :) I also used an implementation detail of permutation, which is always ill-advised.
I wanted to keep the whole computation lazy, hence the gather/take. The lines routine is lazy so it's fine. But I guess if we use hyper operator on it, which I believe is eager, then the laziness is lost. Ironically, eagerness might just be faster, but we are writing Perl 6 so what's one or a few more seconds anyway :)
I didn't have the time to think about the second part. But I intuited that [Z] to transpose (I feel thrilled to even think about it) and rotor(3) to neatly divide could work. Another poster pulled it off expertly (which I see that you have found).
But whatever works. That's the beauty of this language. This might just be the only opportunity I will have to write some Perl 6 in a year, so I am a bit miffed about missing a few days already. Meanwhile, evidently I need to do quite a bit of brushing up because it took me embarrassingly long time to remember/write mine.