jeudi 7 mai 2020

Shuffle each line in a file a certain amount (control degree of randomness) using Python

I have a file which contains a number on each row. I want to be able to shuffle each line around the file but only within certain boundaries i.e. shuffle each line ±1 or shuffle each line ±5. Essentially I want to be able to control the degree of shuffling with the end goal being several different outputs, some of which only deviate from the original file slightly (each line is in approximately the same position) while others differentiate by a large amount (each line is far away from its original position) and everything in between.

I have seen plenty of questions asking about straight up random shuffling every line but I haven't been able to find anything about being able to control the degree of "randomness".




Aucun commentaire:

Enregistrer un commentaire