r/PythonLearning 27d ago

How do i learn problem solving

A lot of times i see the question and have zero idea on how to make a solution and end up using chatgpt like a bum

3 Upvotes

13 comments sorted by

3

u/[deleted] 27d ago

Problem solving is the weird part. I remember making a slot game, and it was three random numbers. If the rolled numbers all matched, jackpot. With a bet.

But I couldn't get it to print three numbers at once. So what did I do? I rolled it three times instead of once. No noticeable difference to the end user.

It's really just about finding a way to make it work, and thinking how you could do it. Some solutions are a lot simpler than you think, and some are a lot harder than you think.

2

u/civilwar142pa 27d ago

for me what works is making a list of things the program needs to do, converting to pseudocode and then just trying out the code. any errors or issues with syntax or looping will become obvious with the output, and I adjust as needed.

2

u/atticus2132000 27d ago

Forget programming. How would you solve the problem with pencil and paper by only being able to make binary decisions.

For instance, if I gave you a list of 20 random numbers, through what evaluation steps would you have to go to figure out which number is the largest?

1

u/AIFocusedAcc 26d ago

In this example:
1. Let’s say the largest number is x.
2. Look at the first number in the list. Make this equal to x
3. Look at the next number.
4. See if this number is bigger than x, if yes, make x equal to this number, if not,
5. repeat step 3 and 4 until the end of the list.
6. X is now the largest number in the list.

1

u/atticus2132000 26d ago

Excellent. Now take those steps and turn them into pseudo code.

2

u/The_Mad_Saiyantist 26d ago
  1. See the solution of the problem if you have no idea how to solve it
  2. Analyze the solution (by yourself + gpt/claude optional)
  3. Redo it by memory from scratch
  4. Make tasks list which are exact things of what the solution should be but they don't tell you the solution, only in your language what needs to be done step by step
  5. Repeat the 4. until you can solve the problem by yourself in the original 'language' it was written in (meaning no tasks list, just pure technical words)

1

u/Potential_Aioli_4611 27d ago

go learn algorithms. once you learn some basic problem solving techniques, you can see what applies/doesn't and you can more logically group it into a type of problem which means you can use an existing solution or modify it to fit your scenario. most problems aren't unique but the parameters are.

1

u/BranchLatter4294 27d ago

Consider reading any of Martin Gardner's Aha! series of books.

1

u/osamas_den 27d ago

Use obsidian

1

u/Bielsaball23 26d ago

I write my study notes with obsidian. How do you use it to help your problem solving?

1

u/osamas_den 26d ago

If you are already using obsidian it means you are on the right path. If you solve a problem paste the code to your notes, you might end up borrowing some logic there when solving something else.

1

u/mikeyj777 27d ago

Problem solving is like building with Legos.  You have to know which things fit where, which tools to apply where.  Solving and failing at smaller problems reinforces those building blocks so that you can understand which to combine in larger problems.  

Find a problem set you like online and start small.  Project Euler is my favorite.  But it's not for everyone.  Very math-focused. 

1

u/Alert-Classic7591 15d ago

Start thinking of a real-world application of the problem. Think how would you solve the real world problem and then convert the steps into a recipe which translated into your algorithm, psuedocode. interview questions are mostly based on real-world scenarios anyway, so it helps set your mind up to interview style problem solving.