I failed my tech challenge today for a job interview. I don't think I was given a fair chance



Can we use chunk_every/4 here? What if the words we are looking for is the last word of the first chunk and the first two words of the next chunk?


3rd argument of Stream.chunk_every/4 is the “jump”. So if “jump” is smaller than window then you can control what will happen in window. As I defined jump to be one, it will give me stream of all 3 consecutive words sequences.

iex(3)> [1, 2, 3, 4, 5] |> Enum.chunk_every(3, 1)
[[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5]]

my god, this is really cool, i honestly thought this chunk piece was the trickiest part of this interview question.