Advent of Code 2017

The problem is not in the filter, I’m using Stream.filter with Enum.empty?, so this stops as soon as we find the first severity for the given delay. The number of inner comparisons should in fact be the same. However in my solution there are three indirections in the inner loop (Stream.filter, Stream.map, and Enum.empty?), and this is where I guess the problem is. With the loop being tight and long, and inner calculation very simple, the overhead of streams seems to dominate a lot.