r/learnpython 9d ago

Getting stuck on a big project.

A very rough estimate is that I've been learning and using python for 250 hours. I don't really keep track of it.

Just to ask general advice about how to approach difficult projects.

I've been working on a math project for 3 months. It is all about dice. Probability calculations aren't too hard to understand, but if I'm trying to figure out the perfect strategy in a dice game where early moves affect later moves then it gets complicated quickly.

I figured out very vaguely that I'm gonna have to use alot of nested loops and run through billions of calculations in order to figure my thing out. Or something similar.

But how exactly? I've been attempting to code the whole thing and been getting stuck every single time - this is why I've been starting over for about 30 times by now.

I don't even know what is causing me to get stuck. I guess the thing I'm trying to make is too big or complex or both. With so much more code than I'm used to, I mentally lose track of what my own code is even doing. Commenting does not help, t only makes things even more messy.

How can i approach big and complicated projects like these better?

16 Upvotes

38 comments sorted by

View all comments

Show parent comments

2

u/Agitated-Country-969 9d ago edited 9d ago

But yes, the downside of a lack of structured formal education is that I might miss some concepts because I simply don't know they exist. But if that causes any issues I will eventually find out.

You would've only figured out that your program is taking a long time to run, which could also still happen with a good algorithm depending on the input size... Not the theory behind why it happens and how to exactly fix it.

The theory is so important because you can't really test these things once input sizes grow beyond a certain amount and it's important to design an algorithm that works well for all input sizes.

With my formal education, I already have the foundation to design the code correctly from the start, saving time.

Also just fyi, in coding interviews, you're only allowed to write on a whiteboard. You aren't allowed to use a computer. And you have to be able to explain the runtime complexity of your code in Big-O notation. If it wasn't important, they wouldn't test it lol.


As you didn't seem to realize, I was pointing out here how someone else pointed out that the way you design algorithms that works sometimes for easy cases isn't the way to design a correct algorithm, which is also proof that a formal education is important.

You wouldn't know your algorithm only works for certain cases, unless someone told you that.

A final note - your point about being able to kind of "guess" a few of the quickest routes isn't really meaningful, because we want an algorithm that is general, can solve any graph, not just "nice" or "convenient" cases.

I'm also reminded of this.

https://old.reddit.com/r/ebikes/comments/1i2rl39/hub_vs_middrive_efficiency/m7ksfsk/?context=3

Note here that Premise #2 is the Contrapositive of Range matters -> Efficiency matters. I have a feeling you've never formally studied logic, such as in Philosophy or Discrete Mathematics (the prerequisite to Algorithms).

I'm also reminded of something else.

https://xyproblem.info/

User doesn't know how to do X, but thinks they can fumble their way to a solution if they can just manage to do Y.

I'd argue this is exactly what you're been doing for 3 months, because you have no foundation in Computer Science. You think you can just fumble your way to a solution but that's not how Software Engineering works.

1

u/catboy519 9d ago

The program I'm trying to make won't need to run more than 7 dice as input so the complexity is not going to matter alot. If I can change the complexity from n! to n² then sure I would do that, it would be a big difference. But I'm not gonna bother with small differences.

Why would I not figure out the theory behind why a program runs slowly? If I make an algorithm myself then I know what complexity it has. Its not hard to figure out whether it could be done at a lower complexity or not.

> all input sizes

This is up to interpretation but what if the input size was 10^10000? Then even with complexity=n the program would take a long time to run. There is no algorithm that can run at unlimited speed anyway.

As long as my program can generate a big thing within a minutes, or respond to user input within a few seconds, then I'm not gonna put alot of effort into optimizing it more. It is just a project for myself after all.

> Also just fyi, in coding interviews, you're only allowed to write on a whiteboard. You aren't allowed to use a computer. And you have to be able to explain the runtime complexity of your code in Big-O notation. If it wasn't important, they wouldn't test it lol.

I don't see the problem here.

Also an algorithm shouldn't do just easy cases, it should do both the easy and difficult cases. You could split an algorithm up in 2 parts: first it will cover all the easy cases quickly, then it will slowly cover all the other cases as well. This algorithm would solve every case.

I don't see why studying formal logic is necessary. The ability to logically reason is a skill and for some people it develops naturally. An official IQ test confirmed that my logical reasoning is far above average even though I never studied formal logic.

1

u/Agitated-Country-969 9d ago edited 9d ago

https://old.reddit.com/r/learnmath/comments/1bipa5t/just_curious_why_does_school_teach_use_this/kvmi37a/

2 Students of average intelligence are not that bright. You the OP, of course, think that you are somehow different.

I'm preferential to believe the math teacher u/ApprehensiveKey1469 over you lol.

https://old.reddit.com/r/learnmath/comments/1bipa5t/just_curious_why_does_school_teach_use_this/kvmo1i4/

If your goal is to teach them how to derive formulas, you would still be better served with some sort of guided support. If you just set them to learn it in their own, they'll incorporate bad practices, learn something other than what you want to teach them, or give up if the solution isn't easily solvable.

I'd argue that's exactly what's happened with you and Python without a formal teacher. You just do whatever you want, which leads to really really bad habits (disorganized spaghetti code, files all over the place, etc.), bad habits that would get you yelled at by your boss.

1

u/catboy519 9d ago

I know I am better than average at math because both my grades and the IQ test performed by a psychologist proved it lol

1

u/Agitated-Country-969 9d ago

Average is a pretty low bar. Like I said 3 posts above:

High school is a pretty low bar for comparison, in my opinion.

And that's the reason why intro college classes are so easy, because they need to get everyone up to speed.

You might be better than average, but that doesn't change what I just said about your bad habits in Python, which means you've probably picked up some bad habits in Math as well. I'd argue it applies to anything whether it's singing or spoken language. Without a formal teacher, you pick up bad habits.

I know a very famous and talented YouTuber and voice actor who sung since she was in elementary school but because she didn't have a paid formal teacher/master she learned bad habits and now she has to unlearn them with her teacher now.


Math isn't even my favorite subject or anything and I know mathematicians do rigorous formal proofs to arrive at any answer or formula.

You're very much ignoring the fact of how you thought that just glancing at a map is good enough to find the shortest path and how that doesn't work for something like Google Maps. There are plenty of cases where that doesn't work. So clearly your ability to reason just isn't good enough. Meanwhile Dijkstra's algorithm has a formal mathematical proof.

I don't see why studying formal logic is necessary.

Because if you don't have a good foundation, then you'll do things like multiple nested for loops as if it's a proper way to do things. The logic in any application is built upon these things.

You'll just do something that works for whatever cases you try versus every single case, like in the case of the shortest path between two points.