13
votes
Day 1: The Tyranny of the Rocket Equation
Today's problem description: https://adventofcode.com/2019/day/1
Join the Tildes private leaderboard! You can do that on this page, by entering join code 730956-de85ce0c
.
Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python
with any of the "short names" listed in this page of supported languages):
<details>
<summary>Part 1</summary>
```python
Your code here.
```
</details>
Gotta play catch up as well.
Parts 1 and 2
I'm using Python :)
Part 1
Part 2
Copy-pasting some suggestions I made for someone else's Day 1 Python solutions with some comments about cleaner/idiomatic ways to do some things. It should be useful for you too, if you want to be a little more "Pythonic" about it (I'll only do Part 1 since Part 2 is very similar):
Part 1
I'm doing these in Python! I am a little miffed that this challenge wasn't the ideal rocket equation.
Parts 1 and 2
I think you need an empty line between the summary and the code block
Indeed I did. Thanks for the reminder!
Well, I'm already behind on the days...but here's Day 1.
Part 1 + 2
Non-recursive function is part 1, recursive function is part 2.
Hardest part was finding out how to read from a file and parse the strings to numbers. I stole this person's solution, though I probably could make it slightly more efficient by not adding the numbers to a vector and just calculating the sum outright. I find that with these problems where efficiency isn't really a factor I like to store stuff in vectors as a kind of paper trail. I can print the vectors out and observe trends or note where things might be added wrong, etc.
Anyhow, the code:
Quick
awk
solution.Part 1
Part 2
Language: Rust
I initially thought that we had to run the rocket equation on the total mass of fuel instead of each module's fuel, so my initial answer was high. But, that was just me misreading the instructions.
Part 1
I got a little carried away with argument parsing in my main function... It's way too complicated. I should have just assumed there would be one file. Oh well.Copy pasted from my comment in the original thread
Day 1: The Tyranny of the Rocket Equation
Part 1
This was pretty simple. I'm sure it could be condensed down.
Part 2
I'm not entirely sure I needed to use a function here. But it was easier for my brain to work around it that way. This one made me think a little with the whole calculating the weight of fuel needed for fuel.
It's not very pretty
Both parts