Einzelnen Beitrag anzeigen

Kas Ob.
Online

Registriert seit: 3. Sep 2023
214 Beiträge
 
#8

AW: Stringlist in zufällige Reihenfolge bringen

  Alt 7. Sep 2023, 16:40
No sure if I understand the question 100%, but I would solve this by not using for-statement, it will just complicate the restrain the algorithm.
I think "While-do" or "Repeat-until" loop is better approach, something like:
Code:
  while Count < Required do
  begin
    SelectAtRandom; // from the pot
    if SelectedIsOK then
      begin
        StoreInList;
        Inc(Count);
        // Here we could adjust the selection condition like remove elements from the pot
      end; // else we pick again and ignore the selected
  end;
SelectedIsOK can be be multiple conditions, like simple check if the current pick artist is not the last (or 2nd,3th) artist in the selected list.
  Mit Zitat antworten Zitat