I do my best to remember what I have learned, to think outside the box, to be creative and break the code into smaller parts when necessary, but it is not always easy to do so.
CodeCombat sometimes asks me to complete a level with x line of code. For example: "Use 8 lines of code" and another which offers a greater reward with "Use 4 lines of code". I usually manage to complete the level with the lowest maximum line of code and sometimes even less than that which makes me feel great!
Problem-solving is one of the most important skills a programmer should have as programming is about problem-solving as well as writing lines of code. There is more than one way to solve problems and I wonder what other people's approaches to problem solving are.
Do you have a particular approach to problem solving? Do you have a step method or something which you follow? What is your approach to solving problems with code?
I tend to find that if a Developer is going to go "off the reservation" they'll do it in chasing that bit of optimization that gets us from 6 lines to 5 or whatever... so I try to stay focused on the words "Solving Problems" rather than "with Code".
First iteration: Solve the problem.
Second: Clean up egregious stuff.
Try to stop there unless new information comes to light or unless the system is life-and-death - because otherwise, you can spend a lifetime tweaking something - the returns diminish rapidly.