Basic steps of solving programming problems:
- Find the input.
- Find the output.
- Figure out how you need to transform the input to the output in plain English.
- Translate this into your chosen programming language.
- Run the code (in your head, or on a machine).
- If the output isn't what you expected, start over with step three.