Challenge
You task for this question is to split an input array of integers on the second occurrence of every integer in that array.
Not clear enough ? Here is an example to help
Input array:
[2 1 1 2 3 2 2 4 5 6 7 3 7 0 5]
Output:
[[2 1] [] [3 2 2 4 5 6 7] [] [0] []]
Explanation:
Here is the array with just the second element highlighted in bold:
[2 1 1 2 3 2 2 4 5 6 7 3 7 0 5]
Now we put the splitting array blocks around these bold second occurrences:
[2 1] 1 [] 2 [3 2 2 4 5 6 7] 3 [] 7 [0] 5 []
and wrap these splitted arrays in an array to get the final
[[2 1] [] [3 2 2 4 5 6 7] [] [0] []]
Note that when adjacent second occurrences occur, there will be empty arrays.
Rules
As usual, you have to write a full program or a function taking the input array via STDIN, ARGV or function argument.
Input
The input consists on any convenient array (or array-like) format of integers.
For instance, any of the following would be acceptable:
2 1 1 1 4 5 6
[2 1 1 1 4 5 6]
[2, 1, 1, 1, 4, 5, 6]
Output
When outputting to STDOUT, your array can also be printed in any convenient (nested) array format, e.g. one of
[[2 1] [1 4 5 6]]
[[2, 1], [1, 4, 5, 6]]
{{2, 1}, {1, 4, 5, 6}}
(This will usually be the native string representation of arrays in your language.)
Also note that trailing empty arrays should be printed as the part of the array.
Scoring
This is code-golf so shortest code in bytes win!
""
as the empty array? This smells of favourism towards a specific golfing language. \$\endgroup\$2 1, 1 4 5 6
? \$\endgroup\$