Hey everyone! I'm looking to sharpen my problem-solving skills, but I'm often confused about what a coding problem is really asking. The wording can be tricky, and I struggle to break it down into smaller, manageable steps. I'm not looking for help with a specific problem at the moment; I just want to understand how you tackle understanding coding questions in general. Do you have any methods or checklists you follow when you come across a new problem? How do you figure out the input and output, what you're supposed to do, and how to start thinking about the logic? Any advice, examples, or tips would be greatly appreciated! Thanks in advance!
6 Answers
A technique I use is to write a basic program with placeholders first. For example, I start with something like `$output = doTheThing($input)` and then refine it as I go. It helps me see where I need to make adjustments along the way!
Sometimes the wording of a problem can be confusing, and that might not always be your fault. A good approach is to break down the problem into sections. You could try sketching a diagram or explaining the problem to someone else to get clarity. Also, remember, a lot of this skill comes with practice, so be kind to yourself!
You might want to check out some classic books on problem-solving, like those by Martin Gardner. They can provide some useful strategies and insights!
I don't think there's a specific checklist you need to follow for every problem. Just keep practicing coding problems — start simple and don't give up until you've finished what you started. Over time, your understanding will naturally improve.
Try to approach the problem from two angles: top-down and bottom-up. Begin with the big picture and break it down into smaller parts, or start from the smallest piece that you know you can solve and build up from there. You could also find similar problems online to get inspiration. And don't forget to write down the documentation for what you're trying to do; if you can't explain it, you might need to rethink the problem!
Using an IPO (Input-Process-Output) model can be super helpful! If you can establish that, you're halfway to coding the solution.
Thanks for the advice, bro!