All problems

Generating a Random Test/Train Split Order

mediumPythonNumPynp.random.permutation

Before a dataset is cut into a training part and a test part, its rows have to be put into a random order. Datasets arrive sorted by something — collection date, customer id, class label — and cutting a sorted file in two hands the model one kind of row to learn from and a different kind to be tested on. Kestrel Media does the shuffling on the row numbers rather than on the rows: it produces a new order of the numbers 0 to n-1, leaving the dataset itself untouched, so the rows can be read through that order. The split has to be reproducible across runs, so the classic global random stream is set from a recorded seed first.

Task: Print the shuffled row order.

Input

One line holding two integers separated by a space: the seed, then n, the number of rows in the dataset.

Output

One line holding the n row numbers in their shuffled order, separated by single spaces, each a plain integer. Every number from 0 to n-1 appears exactly once.

Example:

Input:
1 5

Output:
2 1 4 0 3

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…