I have a duration say 400 seconds. Now in this duration I have to position sub durations like 5 seconds, 90 seconds, 20 seconds, 40 seconds as randomly as possible. See image below

I am not able to come up with any logic in C# coding. One PSEUDO logic that I have in my mind is to PLACE all sub parts at the BEGINNING and then take the RIGHTMOST and distribute it to the place available from the right most part to the end and keep doing it. Problem with this approach is that in case it arranges just right of it's current location, then there will hardly be any spaces in between.
Can someone suggest something, even pseudo code will do. Didn't give my code because it is not giving any randomness.
Thanks Sujit
Источник: https://stackoverflow.com/questions/781 ... r-duration