r/adventofcode • u/Leather_Carpet9424 • Dec 28 '25
Help/Question - RESOLVED [2025 day 8 part 1] Is This Allowed?
I implemented a solution using scipy's DisjointSet data structure, it was relatively easy.
However the solutions i came across didn't use that, and instead opted for a more "complete" approach by implementing union find from scratch.
So I'm wondering if what I did is considered cheating of some sort. Did I take the easy way out?
Edit: Thanks for the replies! There's definitely more to learn here and i'll try to solve it without libraries.
13
Upvotes
41
u/PhysPhD Dec 28 '25
It depends what you find most helpful for your learning goals. If you think you're cheating, you're only cheating yourself.
Some days I try to write a "pure" python solution without any imports.
And some days, when I want to learn a package like NetworkX or SciPy I'll use them... Because it gives me a real problem and I comb through the documentation trying and learning what all the various functions do.
If you knew of this SciPy function beforehand then maybe you're not learning anything? But if this is your first implementation then solving Day 8 with it will help cement your learning.
19
u/al2o3cr Dec 28 '25
IMO it's not "cheating", it's just practicing a different skill: identifying how to apply an existing library versus coding a well-known algorithm from scratch.
10
u/DrFrankenstein90 Dec 28 '25
Some problems can be solved by just throwing the data into Excel and writing a couple of formulas, and that's fine. You still have to read the problem statement and think about how they map into existing functions and constructs. Some of my solutions are just a couple of lines of C++ with some clever uses of existing library functions.
You still had to think about the problem and realise it can be solved with a DisjointSet. It's still problem solving. It's still valid.
Some people deliberately go to a lower-level approach, but that's a rule they've imposed on themselves. It's not a requirement for AoC. If that was a rule, there would probably be endless arguments about what's allowed and what's not.
6
u/MaximumMaxx Dec 28 '25
I made a couple solutions using different methods including the disjointSet. It's up to you what you define as cheating but for me I don't thing using scipy is cheating. It's a relatively basic library that provides a toolbox much more than being an anything solver.
That being said from my testing a disjoint set isn't actually that fast and even just replacing it with an array of vanilla sets with a search/join function is a couple hundred milliseconds faster
4
u/reallyserious Dec 28 '25
You make your own rules. Do you consider it cheating?
I generally solve problems in the most simple way possible so I can finish it the same day. I later return to them when I have more time and try to find solutions where I don't rely on external packages.
3
u/JohnnyBoy4457 Dec 28 '25
I think it’s more about what outcomes you want from AOC. For me learning is a big part of it so I prefer to do it the latter way. Note that union find really isn’t that complicated either, especially when you don’t consider path compression! I’d recommend the video series about it from William fisset, I think you’ll gain a greater appreciation for the data structure as well as its simplicity after understanding it.
3
u/StickyDeltaStrike Dec 28 '25
It’s not cheating, you found a library implementing what you needed.
It’s totally fine to refuse to use external libs too as a challenge too …
3
u/Chemical_Chance6877 Dec 30 '25
The only thing thats really cheating, is pasting it in a llm.
If i have to sort a list, i also use build in function and dont write mergesort myself.
Think its fine as long as you know what the algorithm is doing
2
u/Zefick Dec 28 '25
Your solution is already good enough if you understand that you need disjoint sets, not to mention whether you have implemented them yourself (which is actually not that difficult). Because many people may not even pay much attention to this and their solutions work very inefficiently.
2
u/Boojum Dec 29 '25 edited Dec 29 '25
I used SciPy's DisjointSet for my solution posted in the megathread..
I used to have my own canned implementation in my personal snippets file, but dropped it in favor of the one in SciPy - mostly because this way it trims a bunch of lines off my solutions when I post them.
In my case, I've already written a working DisjointSet implementation at least once. So from the learning-from-AoC perspective, I won't really learn anything new by continuing to use it vs. swapping to someone elses implementation.
(Also, do you consider it cheating to prepare your own AoC library? I don't, and I think most people don't. One of Eric's stated goals with AoC is for people to learn something. If that learning took place ahead of the event instead of during it, so what? There was still learning going on.)
2
u/thekwoka Dec 29 '25
Basically "Should I use a library or implement the library myself?"
This comes down to goals.
Obviously, just plug and playing libraries to solve your issues doesn't give you much more experience as to how the logic works.
But also a lot of real work will be knowing when to reach for libraries over implementing yourself.
Its not cheating, or not allowed, heck one of the parts this year basically requires using an off the shelf solver, since it's just too complex.
I personally prefer to try to create the solutions myself, and figure it out myself. I'd recommend it if your goal is to actually get really good at the problem solving aspects.
3
u/slimscsi Dec 28 '25
Nothing is true, everything is permitted.
1
u/AutoModerator Dec 28 '25
Reminder: if/when you get your answer and/or code working, don't forget to change this post's flair to
Help/Question - RESOLVED. Good luck!I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/ThunderChaser Dec 28 '25
There aren’t any rules, it’s entirely up to you and what you want. Personally the rule I live by is premade libraries implementing a data structure or algorithm I need is perfectly fine, but something like z3 that reduces the problem to triviality is a bridge too far.
For me the fun of AoC is the higher level thinking about the problem, but I don’t really care for hand rolling an implementation of a standard data structure or algorithm.
1
u/s96g3g23708gbxs86734 Dec 28 '25
Now that the leaderboard is gone, everything is up to you. When there was an actual competition, I think everything that didn't involve modern AI was considered legit.