Keep notes of everything coming out. Take a break whenever necessary to re-organize the solution. Write code for the skeleton of the solution whenever the thinking is clear. Refine the skeleton whenever necessary and fill out the content of the skeleton as the solution details become clear.