dimanche 31 janvier 2016

Generating an array of partially random boolean values based on certain criteria

I am trying to generate random data based on some criteria. I am stuck on how to start so I don't have any code.

I just want some guide on how I can achieve that. You need not provide complete code.

So, coming to the problem, lets say we have this existing data:

Total - 10
Won   -  7
Lost  -  3
Longest Winning Streak - 5
Longest Losing Streak - 2

Now I need to generate an array of random boolean values (true representing a win and false representing a loss) which fulfills the above criteria.

So, in this case the output can be any of the following:

0011011111
1111101100
1010011111
..........

Its the streak part that bothers me. If it weren't for the streak, I could have generated seven 1(s) and three 0(s) and then randomly shuffled them.

Note: I would prefer solutions in C#, VB.NET, JavaScript, or Python but any language is welcome.




Aucun commentaire:

Enregistrer un commentaire