We want to split segments from an input file into segments and write segments into many output files.
In the input file we have a sequence of arbitrary unsigned characters.
We first split this string using delimiter
Then we write each segment in order to the output file that has the minimum number of characters.
If there are more than one file having the minimum total number of characters, we choose the one with the smallest index.
The following animation shows how you split the sample file.
The first line is the input file name. The second line is the number of output files $N$. The third line is the prefix of output files. The length of the file names are all between 1 and 50.
- $1 \lt N \leq 10$
The output file names should have the prefix from stdin, the followed by its index (from $1$ to $N$).
If the prefix is
output and $N$ is 3, then the output file names are
Sample Input 1 (stdin)
Sample output 1
Sample Input 2 (stdin)
Sample output 2
Sample Input 3 (stdin)