samedi 9 novembre 2019

Get N random non-overlapping substrings of length K

Let's say we have a string R of length 20000 (or another arbitrary length). I want to get 8 random non-overlapping sub strings of length k from string R.

I tried to partition string R into 8 equal length partitions and get the [:k] of each partition but that's not random enough to be used in my application, and the condition of the method to work can not easily be met.

I wonder I might I have to use the built-in random package to accomplish the job, but I can't think of a way to do it, how can I do it?




Aucun commentaire:

Enregistrer un commentaire