Problem Solving

Problem solving is a problem!


  1. understand solution medium
    • whiteboard, editor, meeting?
  2. confirm the problem
    • what is input?
    • what is desired output?
  3. analyze the problem
    • identify variables
    • identify computed facts
      • lengths
      • locations
    • ask question
  4. work through medium-sized example
    • one may be given to you
    • draw
  5. work through tiny examples (edge cases)
    • "0 or 1" examples
    • "perfect" examples
    • "no work" examples, e.g. list already sorted
  6. reanalyze problem given new context
  7. state solution idea(s)
    • always state a brute force solution
  8. iterate "high-level" solution
    • define facts
    • define the primary function that solves problem
    • define additional function that do actual work
  9. analyze hotspots
    • "off by 1" errors
  10. tests

HGPA's Interview Question Heuristic

Survey the Workspace

Is it a whiteboard, a piece of paper, or is it a discussion with a group? Perhaps it may be on a computer in a text editor or IDE. Understand how to use each of these mediums effectively. This is the essence of the programming environment.

Understand the Domain

This is the essence of programming arts.

Understand the Problem

If a problem is spoken to your then write it down. Repeat or present your transcription and confirm that it is correct. This is the essence of requirements and specification.

Remember that every problem is essentially function: it has one or more inputs, and an output. Understand the types and domains of your inputs and outputs -- this include upper limits. Sometimes the inputs themselves are complex.

Remember that some problems are still problems because of how they are stated. Information may be implied or hidden. Sometimes necessary information is not supplied at all.

Develop Test Cases

Stating various simple and extreme combinations of inputs and their known outputs will help determine error cases, base cases, edge cases, and cases that should run through conditional statements. This is the essence of unit testing and code coverage.

Remember that a complex function can usually be composed of various smaller functions. Use this to separate concerns and isolate bugs.

Remember that the development of a solution may imply additional test cases.

Work the Problem

Work the problem with the your primary computer: your mind.

Sometimes it is easy to break down the problem into smaller subproblems.

Develop a Solution

Understand this may not be the best solution, but it is a solution.

Test the Solution

Analyze the Solution

Is there another way? Is it better or is it a trade-off? Do you have the time to consider another solution or is this good enough considering the range of the inputs? This is the essence of scaling and project management.

If the solution needs to improve, then return to Work the Problem with a new attacks.

Filename: problem-solving.md (Edit)
Modified: 2017-05-21 (78cea39eb7569e8dbd4a3c52f4bcaf8ed4161ed8)
Created: 2017-05-21 (78cea39eb7569e8dbd4a3c52f4bcaf8ed4161ed8)