For Greedy in Pset1 I have everything right except I have no idea how to track how many times a loop is run so it gives me how many coins I need. Or maybe there's another way to get the solution? It wasn't in the walkthrough or any of the lectures or shorts, that I saw, maybe I missed something? If you could point me to where I could find the info or just tell me if there's a function I could use, that would be great.
1 Answer
to track how many times a loop has run, you would create a variable outside the loop (e.g. called counter, then inside the loop, after it is done its other operations, increment the counter with counter++ so that every time it goes through the loop, it also increments the counter.