Lets say we have this existing data:
Total - 10 Won - 7 Lost - 3 Longest Winning Streak - 5 Longest Losing Streak - 2
Now you need to write a function which generates 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 ..........
- Solution must be function which takes in
Won, Lost, Longest Winning Streak and Longest Losing Streakand returns a boolean array or string formed of a boolean array like (
110011001010). It can also display output instead of returning the generated data.
- You can safely assume there are no ties/draws/no-results.
- This is code-golf so shortest code wins.
- Input format can be in any form (Standard Input/Command-Line,etc.). And the real input format should be -
<Won> <Lost> <LWS> <LLS>where
<..>are place-holders or they can be separate parameters for the function.. whatever you deem best for your code. The parameter
Totalis unnecessary. So you needn't use it.
- As far as random is concerned, you can see that in the example, there are three (and more) possible outputs. Just output any one at random.
- If you have any other question, ask in the comments below.
Important - Not any answer as of now is correct.
I provide another example (this one's real data) which is possible but not working with the codes in the current answers:
Total - 171 Won - 111 Lost - 60 Longest Winning Streak - 10 Longest Losing Streak - 4
Another possible output (Basically the same, just the third and fourth digits are interchanged):