Given a collection of facts, we would like to get rid of as much redundancy as possible.
The facts involved in this problem are members of a transitive relation between
uppercase letters. So each fact is a pair of uppercase letters such as AB
meaning that A is related to B. A letter may or may not be related to itself,
but transitivity holds: if A is related to B and B is related to C then we
can infer that A is related to C.
Create a class FactCount that contains a method minFacts that is given a
String[] known and that returns the size of the smallest set of facts that
will allow us to infer everything (and only those things) that can be inferred from the facts
contained in known.
Each element of known will contain 1 or more facts separated by a single space. The smallest set of facts may contain facts that can be inferred from
known but that are not contained in it.
|