14
votes
Day 1: Secret Entrance
Today's problem description: https://adventofcode.com/2025/day/1
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>
Doing this year in a little-known scripting language I've been writing a game with in my spare time (https://lily-lang.org). It's an embeddable scripting language like Lua, but with static typing - an interesting niche I haven't really seen covered elsewhere.
I agree with others that this was harder than the typical Day 1 puzzle, but it still wasn't too bad. I took some time after initially solving it to try to figure out a cleaner solution, but eventually just gave up and committed my original code. The input was small enough it didn't really matter.
Solution (Lily)
The language looks cool, but that website is phenomenal! I want every site for a language to be as simple and organized as this. Exactly the information I want without any extras in the way.
I have to ask based on the username, is this a language you're connected to or just a happy coincidence?
Just a coincidence! I found the language earlier this year when looking through a list on GitHub of embeddable scripting languages, and thought it looked interesting. I have contributed some functionality to the standard library (mainly a sort method for lists and a small UTF-8 module), but I'm not the developer of the language itself.
I'm not sure how much I'll do this year, but here's P1 and P2 in Google Sheets
The Formula
My topic about the Excel World Championships inspire you to give spreadsheets a try again for AoC? ;)
haha that and its really all I'm good at in this space. Last year I only did a few days -- but I usually get about 3/4 done. Its once we get into the 'build a computer...' that I tap out
Elixir
If anyone is interested, I have a template repository that helps you set up an elixir project for Advent of Code puzzles with some nice conveniences. That’s what I’ll be using in all of my solutions.
I am so glad he’s shortened the event to 12 days, I always spend way too much time on these puzzles and end up neglecting more important things during an already busy holiday month…
Both parts
I wanted to find a cleaner (i.e. more math-based, less branching-logic-based) approach for counting the number of times a given rotation visited position 0, but this was the best I could come up with.
Summary of my approach: Build a list where each element is a map with
:positionand:zero_visitskeys. Each map gives the position of the dial after one rotation specified by the input, as well as the number of times it moved to 0 on its way to that ending position. Use these computed states of the dial after each rotation to get the answers for both part 1 and part 2.Benchmarks
Since I put basically all the work in the shared parse function, "part 1" and "part 2" are simply the logic that sums up the results with one final pass through the list.
Huh, didn't think I'd find someone else here doing it in Elixir.
I might be having a closer look at your code, since I am using the puzzles to learn the language.
I originally solved part 2 with brute force, because I kept getting hung up on corner cases. But I eventually figured it out. Looking at my solution, the cases aren't that bad overall, but it was hard to make sure the cases were mutually exclusive. I was missing the second
elifcase for the longest time.Also, I'm new to python, so if there's anything I'm doing that looks weird or unnecessary or could be done better, please feel free to let me know.
Part 1
Part 2
Looks great!
If you want a tip, it's often preferred to use the
withsyntax for file access, which ensures file closing even with exceptions.So instead of:
you can use:
I probably did not follow the prescribed way to accomplish these. But I did them, and that's all that really matters.
I hope to see other versions for those who are doing it in Rust. I think I saw two other folks on here mention trying it this year, hopefully it'll inspire them to post their solutions when or if they can (no pressure).
Parts 1 and 2 (with tests)
Also I thought it was kind of cute that the second part's hex `0x434C49434B` decodes to `CLICK`I am posting this to remind me to send my solution after work, also doing it in Rust!
Welcome back to AoC!
Part 1 was pretty easy as usual, although part 2 took me a little longer than I would have liked, due to a couple finicky edge cases. Overall, a pretty typical day 1 puzzle and a nice warmup back into it.
Minor general spoilers
There were some fun micro-optimizations to make in this puzzle as well, such as parsing all the input up-front instead of one line at a time. Speaking of, there is also the trick of replacing
Lin the input with-andRwith nothing, to improve numeric parsing.Full code (C#) — As always I'm sure there are ways to make this more concise and maybe even faster, but as-is my benchmarks put both parts' runtime under 500 µs, which is well within my threshold.
Opted to try Prolog for this year. I don't have a clue what I'm doing, and may have bitten off more than I can chew, but I'm loving it so far!
Day 1 Prolog Solution
Spoilers
Originally tried to do part 2 without the full expansion, as it worked almost perfectly with divmod, but gave up after a few frustrating issues and just went the naive route. The style is still pretty imperative, so I'm hoping on future days to try and understand more of the idiomatic approaches.
TypeScript
I'll echo what others have said, this was a markedly harder Day 1 than in years past. I guess that's to be expected for the new compressed 12-day run. Makes me nervous about tomorrow though! Like others, I found Part 1 pretty simple but got hung up on corner cases in Part 2. Ended up just brute-forcing it, which was ironically much more readable than the monstrosity I'd been trying to make work. And it still runs in 5ms on my machine, so no sense in trying to optimize further.
Parts 1 and 2
The step up in difficulty really messed me up.
I spent way more time than I usually would being certain there was just a very simple formula for counting the number of times one would pass over 0 without special cases. It's day 1 after all!
But alas, handling the special cases for the negatives seems to have been necessary all along.
I could have saved myself a lot of time thinking I was missing the obvious.
I'm doing it in Rust this year to get some experience using the language. I'm very familiar with C++ and have used Haskell a long time ago, so I'm not (yet?) struggling with new concepts. For now, I'm mostly learning the details of the syntax and figuring out what's available in the standard library.
Parts 1 and 2
Here are my slightly brute-forced day 1 solutions in Perl.
Spoiler
I was initially tripped up by the counter resets at 0 and 100, hence the slightly clumsy workaround there.
Part 1 (Perl)
Part 2 (Perl)
Normally these topics are automated, but @Deimos is currently on vacation and probably won't be able to set that up very easily where he's at, so I decided to manually post them until he returns.
/offtopic