Click to reopen instructions.

In the last streams assignment you re-solved old array problems with streams. This time the streams are the starting point: most of these methods are handed a stream—an IntStream of numbers or a Stream<String> of words—and have to compute something from it. A few return a stream of their own, and a couple build a stream from a single number.

Remember that a stream can only be consumed once: once you have called a terminal operation such as sum(), count(), toArray(), or collect() on it, it is used up. Most of these methods can be written as a single pipeline from the argument to the answer. If you really need to look at the values twice, collect them into an array or a List first and stream that.

The starter file imports java.util.* and java.util.stream.*, which is everything you need: IntStream, Stream, Collectors, Comparator, and List.

Put definitions here.

Revisions:

Test results show up here.

Errors