adventofcode

Happy Advent 2020! Please put answers in the pinned threads or create one if it does not exist yet. | https://github.com/adventofcode-clojurians/adventofcode-clojurians | Join the private leaderboard with code 217019-4a55b8eb
erwinrooijakkers 2019-12-31T02:55:54.076700Z

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))))

erwinrooijakkers 2019-12-31T02:56:32.076900Z

I think your part 2 can also be shortened using set operations only

erwinrooijakkers 2019-12-31T02:59:17.078Z

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

borkdude 2020-01-03T22:47:08.093200Z

You can see the history of this channel in zulip

borkdude 2020-01-03T22:47:35.093400Z

Go the channel slack archive and topic adventofcode

Alper Cugun 2019-12-31T07:02:51.079100Z

Yeah, I’m plugging away to get comfortable with the language. That’s going pretty well by now.

Alper Cugun 2019-12-31T07:03:27.080200Z

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.

Alper Cugun 2019-12-31T15:19:08.081Z

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 Cugun 2019-12-31T15:22:05.081500Z

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

Alper Cugun 2019-12-31T15:23:44.082700Z

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 Cugun 2019-12-31T15:25:01.083600Z

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

misha 2020-01-01T08:55:10.085700Z

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

Alper Cugun 2020-01-01T09:44:15.087900Z

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 Cugun 2020-01-01T09:45:22.089100Z

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

Alper Cugun 2020-01-01T09:46:30.089700Z

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

uneman 2020-01-01T11:17:25.092700Z

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

đź‘Ť 1
Alper Cugun 2020-01-03T21:13:27.093Z

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

misha 2020-01-04T17:58:40.093800Z

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