Nested loops and basic optimization

Nested loops are one of the most powerful tools in programming, but also one of the most dangerous in terms of performance. A nested loop is simply a loop placed inside another loop. You already know how to write a single loop (the 'while' and 'for' ...