Случайным образом расположите части длительности в большую длительность.C#

Место общения программистов C#
Ответить
Anonymous
 Случайным образом расположите части длительности в большую длительность.

Сообщение Anonymous »


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
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»