jeudi 22 novembre 2018

Generate random number sequences with max n number of repeats in Java

I am looking for a way to generate a sequence of m length of numbers of range from i to j with no more than k consecutive repeats for any of the numbers.

function[i=1, j=3, m=20, k=2]

output = {1, 2, 2, 3, 1, 3, 2, 3, 1, 3, 2, 1, 2, 1, 3, 2, 2, 1, 3}

Something like this but can someone please implement this in Java?

https://mathematica.stackexchange.com/questions/179015/generate-a-random-pattern-with-at-most-n-repeated-consecutive-elements

Thanks :)




Aucun commentaire:

Enregistrer un commentaire