Part 1: find the unique characters for each group in this input. sum the counts.
HashSets make this fairly easy to implement. Given an iterator over
chars, we can filter out newlines (which are chars we don't want included) and
collect into a
sum them all.
Part 2 requires that you count only the characters that appear in every line. We can still take advantage of
HashSet but the
intersection function on
HashSet only operates on two sets at a time 😱 , so we can use the nightly offered
fold_first and some cloning to apply it to all of the sets.