Fork me on GitHub
#adventofcode
<
2019-12-31
>
erwinrooijakkers02:12:17

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

borkdude22:01:08

You can see the history of this channel in zulip

borkdude22:01:35

Go the channel slack archive and topic adventofcode

Alper Cugun15:12:08

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.

Alper Cugun15:12:05

For day 10 I saw one solution with some floating point arithmetic, but wouldn’t the cleaner way be to sieve out?

Alper Cugun15:12:44

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.

Alper Cugun15:12:01

(Doesn’t work for right angles unfortunately. An asteroid at +2,+0 also occludes one at +3,+0.)

namenu01:01:21

yes, so you need to store both angle AND distance. (from nearest to fartest)

misha08:01:10

you can use clojure's ratios for angles, or proper tan/atan from java's Math

Alper Cugun09:01:15

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.

Alper Cugun09:01:22

The the only thing left is to calculate an angle on 2PI with ratios (or to munge floats after all).

Alper Cugun09:01:30

I’ll have to pick up my trig to see whether this is possible.

namenu11:01:25

For error-proof method, you can sort every asteroids clockwise (or counter clockwise) using cross product. It only requires integer arithmetics.

👍 4
Alper Cugun21:01:27

What’s the cross product quality that I would be exploiting here? I’ve never had a good feeling for it.

misha17:01:40

ints sum and multiplication, no fractions and floating point rounding errors