No IntCodes today, just too many asteroids.
Day 10 - The Problem
We home in on the distress call to find the elves trying to find the best place to monitor the asteroids. Of course we need to stop and help them, as this is our best chance of getting through the asteroid belt in one piece.
Part 1 has us scanning for a new monitoring station location, optimized for the best view of the spinning rocks.
With slopes and distances safely under our belt, the elves decide to just blow everything up. Part 2 is doing some calculations to settle a bet on the results of their spinning asteroid destruction laser beam.
Ongoing Meta
Dev.to List of Leaderboards
-
120635-5c140b9a
- provided by Linda Thompson
If you were part of Ryan Palo's leaderboard last year, you're still a member of that!
If you want me to add your leaderboard code to this page, reply to one of these posts and/or send me a DM containing your code and any theming or notes you’d like me to add. (You can find your private leaderboard code on your "Private Leaderboard" page.)
I'll edit in any leaderboards that people want to post, along with any description for the kinds of people you want to have on it. (My leaderboard is being used as my office's leaderboard.) And if I get something wrong, please call me out or message me and I’ll fix it ASAP.
There's no limit to the number of leaderboards you can join, so there's no problem belonging to a "Beginner" and a language specific one if you want.
Neat Statistics
I'm planning on adding some statistics, but other than "what languages did we see yesterday" does anyone have any ideas?
Languages Seen On Day 09
- javascript x 3
- python x 3
- c
- clojure
- kotlin
- ruby
- swift
Completion Stats
By applying a best-fit descending power trend-line to the 1 and 2 star columns on the stats page, my estimates predict:
2 stars on day 25: 6358 people
1 star on day 25: 420 people. Nice
If you're still going, take heart in that you are in a rapidly dwindling pool of people.
Doing other questionable statistics gives me: 415/6248
Top comments (12)
Part 1 of day 10:
JS, spent way too long on this because I was mutating state in a for loop!
Things have settled down a little bit since Christmas, so I've got some time to actually complete AOC2019. Better 4 months late than never! Here's my solution to Day 10. Had some trouble deciding how to handle vertical slopes gracefully, and switching back and forth from global to relative coordinates, but finally got it handled.
Done with part one in swift. need bit more time for part two
Took so much time for part two. Actually went ahead and rewrote part one as well. Solution in swift
An ugly kotlin solution.
I'll clean it up tomorrow.
Ahh... that's better... More Sealed Classes/Discriminated Unions to the rescue. Managed to cut a lot of duplicated code out.
Things are getting complicated now! I like it!
In the first part I tried an arithmetic approach, trying to find - for each asteroid - if there was another one in line with the target location. JavaScript as usual:
The second part showed that it would have been too complex. So I just converted all the coordinates in polar, sorted them out and counted to the 200th asteroid. Finally, converted back to orthogonal coordinates:
Python today. And what a tough problem, especially part 2. Glad that's over.
@jon Guess you added wrong title for this post. It should be Day 10!
I was fixing it just as you noticed! That’s what I get for posting past my bedtime.
JS, I like and hate that you could pass part 1 with a bug in your code, that got me thinking for a while when doing part 2!!