I have a string that consists of 10,000 randomly generated characters but in order to proceed in my project I need to create 100 strings of length 20 from the data set.
I was wondering how I would be able to code this in python so that it picks 100 patterns of length 20 from the string without the chosen strings overlapping no pattern being repeated.
This is my current code to generate the patterns, I am not the best programmer.
Thanks
Since you do not show what you are doing with these and if repeats are or are not allowed, I will give a description of what you need to do.
get the size of the full data set.
generate a random number for starting index. make sure not to overrun the buffer (start index must be at least 20 characters before the end of the buffer
get the slice starting at the chosen index from the buffer and put in your list
delete the slice from the buffer.
loop for the required number of times
Now process your list.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.