Now I am not exactly answering your question (at least not directly) but hopefully you will get some ideas that might be helpful to you.
Well written code can be a lot of things. It all depends on what you want to do.
Efficient code can not only be code that executes fast but also code that are easy to maintain and/or expand. It all depends on your needs.
A good way to start is to break down your problem into simpler problems first and then decide how to solve it. A good way to learn is to read, modify and above all understand other peoples code.
I've once heard a story about a great programmer. He always had a teddy bear sitting next to him and when the code did not work as expected he took the teddy bear on his lap and explained him every line in the code. You see - he actually explained the code to himself. That can sometimes be the best debugging tool since you risk discovering your own mistakes ;)
Also as an example keep in mind that for fast executing code it is especially important to minimize the amount of variables used in a loop. With some luck all your variables can be stored in the CPU's registers for the duration of the entire loop thus avoiding latency for swapping data on the main memory.