Nice 🙂 Happy to see I’m not the only one still doing puzzles. I liked this tip someone gave me earlier:
(let [ys (descendants ::YOU)
ss (descendants ::SAN)]
(count
(set/difference
(set/union ys ss)
(set/intersection ys ss))))
I think your part 2 can also be shortened using set operations only
Can unfortunately not see the history for day 15 here nor on clojureverse, but here’s mine: https://github.com/transducer/adventofcode/blob/master/src/adventofcode/2019/day15.clj
You can see the history of this channel in zulip
Go the channel slack archive and topic adventofcode
Yeah, I’m plugging away to get comfortable with the language. That’s going pretty well by now.
I’m skipping the intcode ones because I originally started this in Haskell and I’m not sure whether I want to port my intcode computer to Clojure.
Looks like I’m not going to get around porting my Haskell intcode computer to Clojure since every other assignment seems to be using that.
For day 10 I saw one solution with some floating point arithmetic, but wouldn’t the cleaner way be to sieve out?
If from a position, there is an asteroid at +2,+1, then all multiples of that position would be occluded so: +4,+2, +6,+3 etc.
(Doesn’t work for right angles unfortunately. An asteroid at +2,+0 also occludes one at +3,+0.)
you can use clojure's ratios for angles, or proper tan/atan from java's Math
A native ratio type is nice. But the approach I saw was to calculate the angle to all others asteroids and then count only the uniques since if any number of asteroids are on the same angle, only one of them will be visible.
The the only thing left is to calculate an angle on 2PI with ratios (or to munge floats after all).
I’ll have to pick up my trig to see whether this is possible.
For error-proof method, you can sort every asteroids clockwise (or counter clockwise) using cross product. It only requires integer arithmetics.
What’s the cross product quality that I would be exploiting here? I’ve never had a good feeling for it.
ints sum and multiplication, no fractions and floating point rounding errors