Don’t understand the downvote, seems apropos to show the direct application of a std algorithm and generic functions to this problem. It doesn’t seem to suit ranges as is because of the complications zipping offset views of the range. At least that’s what I found when I tried it.
11
u/paul2718 Dec 15 '21
Day one can be reduced (sic) to essentially four lines,
But that's not modern C++, more like C++03 if you replace transform_reduce with inner_product...