7
I have been dabbling in Python for some time now and have written some really easy apps. But I alway...
since 2 years, 10 months ago
16 of 16
Tip Reveddit Real-Time can notify you when your content is removed.
your account history
Tip Check if your account has any removed comments.
view my removed comments you are viewing a single comment's thread.
view all comments


TBH for this kind of coding I tend to do everything as data. Python is excellent for that.
Dicts or tuples instead of classes, don't need a formal definition of what's in it if you're the only one using it.
e.g.
Is overkill, just use a tuple:
Just my 2 cents!
If you needed 3d coordinates, would it he just your 3 cents?
I ALWAYS mix up x and y if I don't name them something.x and something.y
Really? it's always x first. Although I do unpack them sometimes like
since point[0] and point[1] is quite ugly if you do it multiple times.
Except when it's row, column. Except when using A1 notation in Excel. But then, everything is a date in Excel.
Just my Jan 02.
You can assume that Excel will consistently behave in the way you least expect it to.
I felt this comment in my bones lol
Except that input[y][x] gives the value for (x,y). I have spent sooooo many hours looking for an error caused by this, I now always take the 3 seconds it takes to make it a Coordinate(x, y) instead of something generic.
I mean you’re the one making the array, nothing is stopping you from making it
input[x][y]. It’s just an indexing scheme.Exactly. That's why I mix them up.
I’ve given up on using x and y in favor of a rows/cols terminology, with a point being (r, c). Rows naturally comes before cols in spoken language, and also when looping over a matrix.
Edit: and (i, j, k) for three dimensions.
Could always use NamedTuples too!
That’s why I usually use maps in Clojure for that exact reason. You can still throw in whatever you like, but have a bit more structure.
I would agree for a one off, but for AoC you will often find yourself doing the same thing again. Having a library of tools is very helpful and you can add or update it as you go. OO can help by using subclassing to keep solution specific code in the solution for a single day.
If I do use something like a tuple in a solution, i'll often look over the code and see if refactoring it into a proper object seems like something that would make it useful to other solutions and/or would have gotten me to a solution quicker.
You're completely correct about that.
But I find doing the overkill structure is a great way to familiarize yourself with a new language and the aspects of it you'd use in a larger project.
Frequently I'll read a task and think "Oh, that'll be easy with an array of tuples", but I'll actually decide to solve it with some more complex structures or language features that would be used for that sort of problem in a larger project.
I mainly work with realtime dataframes up to the length of 80k rows updated by the second.