Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.76 KB | None | 0 0
  1. use strict;
  2. print 'starting';
  3. my @balPos;
  4. my $balArray = "1:11-2:10-3:8-16;1:4-6:3-2:5-16;10:15-12:14-13:11-17;";
  5. my @balances = split(';', $balArray);
  6. print @balances;
  7. my @randBal;
  8. while (@balances) {
  9. push(@randBal, splice(@balances, rand @balances, 1));
  10. }
  11. print  @randBal;
  12.  
  13. my @teams = split('-', $randBal[0]);
  14.  
  15. print  @teams;
  16. my $singlePos = 0;
  17. if ($numberPlayers % 2){
  18. $singlePos = pop(@teams);
  19. }
  20. print  @teams;
  21. my @randTeams;
  22. while (@teams) {
  23. push(@randTeams, splice(@teams, rand @teams, 1));
  24. }  
  25. foreach my $teamPos (@randTeams){
  26. print  '-' . $teamPos .'-';
  27. if(index($teamPos, ':') != -1){
  28.     push(@balPos, split(':', $teamPos));
  29. }else{
  30.     push(@balPos, ($teamPos))
  31. }
  32. }
  33. print  @balPos;
  34. unless($singlePos == 0){
  35. push(@balPos, ($singlePos));
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement