Split the indices 0,…,n−1 into k consecutive folds whose sizes differ by at most one, and build the train/test index pair for each fold. Fold i is the test set of split i and everything else is its training set. Assume k≤n.
Implement solve(n, k).
Returns. Return a list of k tuples (train_indices, test_indices) of NumPy arrays, in fold order. When n is not divisible by k the first nmodk folds get one extra index (np.array_split).
Example 1
Input:
solve(6, 3)
Output:
[([2, 3, 4, 5], [0, 1]), ([0, 1, 4, 5], [2, 3]), ([0, 1, 2, 3], [4, 5])]
Example 2
Input:
solve(5, 2)
Output:
[([3, 4], [0, 1, 2]), ([0, 1, 2], [3, 4])]
No results yet
Run your code to check it against the examples, or submit to run every test.