Split the indices 0,…,n−1 into k consecutive, near-equal validation folds and return, for each fold, the sorted training indices (all others) and the validation indices. No labels are given, so the split is index-based and does not stratify.
Implement solve(n, k).
Returns. Return a list of k tuples (train_indices, validation_indices) of NumPy arrays in fold order. The first nmodk folds are one element larger (np.array_split).
Example 1
Input:
solve(5, 3)
Output:
[([2, 3, 4], [0, 1]), ([0, 1, 4], [2, 3]), ([0, 1, 2, 3], [4])]
Example 2
Input:
solve(4, 2)
Output:
[([2, 3], [0, 1]), ([0, 1], [2, 3])]
No results yet
Run your code to check it against the examples, or submit to run every test.