Suppose you open a file, and do an seek() somewhere in the file, how do you know the current file line ?
(I personally solved with an ad-hoc file class that maps the seek position to the line after scanning the file, but I wanted to see other hints and to add this question to stackoverflow, as I was not able to find the problem anywhere on google)
Here's how I would approach the problem, using as much laziness as possible:
For a slightly less readable but much more lazy approach, use
enumerate
anddropwhile
: