pull down to refresh

What helped me is to think about the logic for a solving a small instance of the problem without loops. Then you can look for repeated code and decompose it into functions. After that, it's easier to see the parts that can be generalized to solve for an arbitrary instance. Wrap those functions in a loop to make the general solution :)
I think of it more like a merry-go-round and each statement is sort of like your position as you go around. At some point the ride stops (you exit the loop), and you get on another ride.
reply