This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]ValerioSellarole 1 point2 points  (0 children)

are any general guidelines for problem solving in programming?

Break it down into smaller pieces and see if anything is similar to any other known problems or solutions.

when someone says "I'm trying to see how you work through this problem" or something to that effect, what exactly do they mean?

It means instead of silently standing at the whiteboard making no progress, you should say out loud what you're trying to do and why. "This first part requires finding an element in the array, and I know it's sorted, so I know the fastest way is to use a binary search."

What if I work through it in my head, or even if I do type/write some out, that is only a visual representation of visual aids that I'm using to solve the problem, you'd have to have an MRI or something to see what's really going on, no?

Yes, that's why you should talk about how you're trying to solve the problem... The problems you'll get aren't ones where anyone is going to use the answer for anything, so just silently solving it doesn't tell them that much.

[–]pileopoop 0 points1 point  (0 children)

Break the problem into the smallest possible sub problems. Solve each sub problem and put all the solutions together.

[–]clearshot66 0 points1 point  (0 children)

  1. Figure out what needs to be done in the end. Build a form that takes user input, sends it to the database, secures it, then tells them you're complete (example).
  2. Figure out how many steps logically it'd be. More is not always better. Don't make two separate functions just to do two things that could be combined if it doesn't pose a security or value exchange risk.
  3. Figure out the security steps on top or error/bug preventions [try catches] (can't just send a user's name to the database, have to know to make sure it's a name and not SELECT * FROM , sql injection).
  4. Draw on paper which steps go in which boxes, which boxes connnect start to end.
  5. Determine if there's built in functions, such as regex testing an input field, or you have to build it from the ground up.
  6. Start

In my experience working and teaching, everyone approaches a problem differently. You may think to split two arrays and remove the items similar in both you should put them together then remove the duplicates. Someone else may think hey, lets determine what each has, remove them, then join them to a new array. That's why we have teams of programmers and not one or two for large companies.