there are some interalized biases that new programmers like myself have towards getting it right in the first go, and thus we keep thinking about it, going in circles reaching nowhere. a better way would be to just quickly put together an unoptimised version of the solution, doesn't have to have a structure or design.
then as you have something which works, it's far easier to just rewrite it a few times before you have a really good solution. this is often faster than thinking more and writing less code. note that this doesn't apply to all situations quite literally, but some form of prototyping (or prior experience with code) is required. iteration is a feature not a bug.