Count the pairs
Write pair_count(n) that returns how many times the inner line runs in
this loop, for a list of n items:
for i in range(n):
for j in range(i + 1, n):
compare(items[i], items[j]) # this line
That is the number of distinct pairs among n items. You can count with
loops or find the formula; both are fine. The point is to see how the
number grows.
pair_count(4) -> 6
pair_count(100) -> 4950
def pair_count(n):
...