NumberOfDiscIntersections - Definition of pair

252 Views Asked by At

Codility has a lesson titled NumberOfDiscIntersections described like so:

We draw N discs on a plane. The discs are numbered from 0 to N − 1. An array A of N non-negative integers, specifying the radiuses of the discs, is given. The J-th disc is drawn with its center at (J, 0) and radius A[J]. We say that the J-th disc and K-th disc intersect if J ≠ K and the J-th and K-th discs have at least one common point (assuming that the discs contain their borders).

Then they provide 6 easy numbers for N. [1,5,2,1,4,0]

circle pairs image ->

It all seems pretty simple at this point. Then follows this text:

There are eleven (unordered) pairs of discs that intersect, namely: discs 1 and 4 intersect, and both intersect with all the other discs; disc 2 also intersects with discs 0 and 3.

PLEASE DO NOT POST SOLUTIONS .. or attempts to cheat the lesson

I am concerned with the question, specifically the meaning of a pair. How they come up with only 11 pairs from this question baffles me.

I guess I need someone likely with a stronger mathematical background water down the definition of the very technical term 'pair'.

1

There are 1 best solutions below

3
On BEST ANSWER

There are six disks (one is just a point)

If you have $6$ objects then there are $15$ ways of choosing $2$ of them. This can be written as ${6 \choose 2}$ or ${\,}^6C_2$ or something similar as a binomial or combinatorial co-efficient and calculated as $\frac{6 \times 5}{2}$ or $\frac{6!}{2!4!}$

So there are ${6 \choose 2}=15$ potential pairs.

Looking at the diagram, four of these do not intersect

  • Disks $0$ and $3$
  • Disks $0$ and $5$
  • Disks $2$ and $5$
  • Disks $3$ and $5$

The other eleven pairs do intersect and these are described in "discs $1$ and $4$ intersect, and both intersect with all the other discs; disc $2$ also intersects with discs $0$ and $3$".