When I looking into some interview questions, I found interesting to solve them without using FOR-loop.
The first thing to do is to group list according to its index. So the input will be list and the output will be a grouped list. Let us start to group the list into two elements unit. The idea is simple:
{ ai } |> { (ai, i) } |> { (ai, i/2) } |> groupby second part
when we have a sequence, we make an element with its index and then we transform its index and group the transformed index. Let me give the code later on.
No comments:
Post a Comment