This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-10
Channels
- # adventofcode (76)
- # announcements (7)
- # aws (3)
- # babashka (75)
- # beginners (25)
- # calva (37)
- # cider (9)
- # clara (4)
- # clj-kondo (17)
- # cljsrn (1)
- # clojure (106)
- # clojure-europe (4)
- # clojure-india (2)
- # clojure-italy (12)
- # clojure-nl (27)
- # clojure-spec (33)
- # clojure-uk (20)
- # clojurescript (103)
- # clojutre (3)
- # core-async (1)
- # cryogen (10)
- # cursive (24)
- # datomic (113)
- # dirac (5)
- # emacs (12)
- # events (4)
- # fulcro (64)
- # garden (5)
- # jobs (1)
- # kaocha (5)
- # luminus (2)
- # malli (14)
- # off-topic (53)
- # planck (11)
- # re-frame (9)
- # reagent (16)
- # reitit (26)
- # remote-jobs (2)
- # shadow-cljs (137)
- # spacemacs (34)
I kept getting the 203 error with day 9. All the tests cases worked. Even the ones made up by redditors but the actual input kept giving 203. Turns out it I left out the "2" in the condition for mode checking. Legit lost 4 hours tracking that down
You were not the only one. 203 seems to have been the biggest stumbling block this day.
hehe, the error code is self-explanatory
For part one I didn't need trig. Part 2 not so sure
Viz: http://quil.info/sketches/show/5d471cd687426dd3ffa006d6c50133e7aed9c984ccada11be36ea06ab5fc5970
so cool!!
I don't get day 10 description, the very first example says only 1 asteroid is unreachable, but looking at the map it's clear there are two of them :thinking_face:
do you mean the top right corner? that one is reachable
if there was an asteroid between the highlighted one and the top right corner, it would have to sit at a position with non-integer coordinates.
“every asteroid is exactly in the center of its marked position”
Oh right, that makes sense. The map put me in Manhattan distance state of mind.
:thumbsup::skin-tone-2: 🍀
My laser already killed astroid 200 on the first round. Lucky I guess
Personal challenge for today, make it fast
don’t forget about threads
pmap
all the things
Want to look more into reducing algorithmic complexity. Using more power is cheating 😉
Current solution is at least O(n^2)
I am checking all other asteroids to see if one is blocking the line of sight which is stupid
Better to determine LoS and see if it has astroids
@mpcjanssen what’s LoS?
line of sight
right now it takes 16 secs want to improve to below 5
any link
wasted too much time on it, so did not clean up https://github.com/akovantsev/adventofcode/blob/master/src/adventofcode/2019/day10.clj
Interesting, did something similar, you can use mod
in your rotate
function to avoid cond->
I think
ah so group by angle and take closest gives the visible astroids immediately
smart, i would just be worried about floating point inaccuracies in the angles.
with the exception that opposite quadrants give the same gradient, so take the sign of dy and dx to disambiguate
I left it to Math/atan2
:
> * <li>If the first argument is positive and the second argument is
> * positive zero or negative zero, or the first argument is positive
> * infinity and the second argument is finite, then the result is the
> * {@code double} value closest to <i>pi</i>/2.
proving again that improving algoritm beats brute force at any day
simpler too
done! Peeling asteroids clockwise from the inside was super easy with mapcat
😉
https://github.com/namenu/advent-of-code/blob/master/src/year2019/day10.clj
there must be an floating point error because i didn't make rational number lowest form..
Hmm my original algorithm was n^3
I have intcode PTSD now so I am afraid to hack together solutions for the sake of solutions and feel the need to write a scalable feature-wise solution.
The angles idea is great! Although I struggled with orienting the co-ordinate frame! @misha
Faffing around in the REPL let me figure it out by recollection and informed intuition. The quickest win for me was (thread for spoilers)
|| to reverse the x and y arguments to atan2
. || From there, you could convert the range by normal means.
When you aren't familiar with the behaviour of a mathematical function, playing with it in the repl can sometimes be good enough. 🙂
REPL driven math?
Pretty much - take a sampling of inputs, examine the outputs to make sure you're understanding your changes correctly. Here, I did a quick guess in my head as to what flipping the coordinates would do, confirmed it in the REPL, and fixed the issue wherein the range was still flipped and offset by 180deg. Quick sampling lets me vet how the function behaved at the edges.
I also tried a bunch of example vectors, [0 1] [1 1] [1 0] etc to get a feel for how atan2 develops
of course I still had to debug the code because I forgot to prefer closer asteroids
things never work on the first run for me
My day 10 solution: <https://github.com/chrisblom/advent-of-code/blob/master/src/adventofcode/2019/day10.clj>
My day 10: https://github.com/pesterhazy/advent2019/blob/master/typescript/src/puzzle10.ts#L1
Took me a while today because (like last year) I had to read up on dot products and atan2