Back to Challenge Set 20

Code Challenge: Step Counter

Difficulty  

divider

The Brief

What they asked for
My developer says one of our two report generators is fine and
the other one will fall over when we grow. I do not know what
that means. Show me some numbers.

Write your requirements list before you write any code. Input, calculate, output, and anything you had to decide for yourself.


Notes

  • You do not need real report generators. You need two methods that report how many steps each shape of loop takes for n rows.
  • One loop over the rows. Then a loop inside a loop.
  • Run both at three sizes at least a factor of ten apart, or the difference will not be visible.
  • Your output has to make the answer obvious to somebody who does not code. That is the real requirement.

Sample Output

Sample Output
10 rows: one loop 10 steps, loop inside a loop 100 steps
100 rows: one loop 100 steps, loop inside a loop 10000 steps
1000 rows: one loop 1000 steps, loop inside a loop 1000000 steps

Ten times the rows: ten times the steps for one loop, a hundred times for a loop inside a loop.


Submit

Your requirements list and your program file, named cc-step-counter.

Commence Challenge