Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- print 'starting';
- my @balPos;
- my $balArray = "1:11-2:10-3:8-16;1:4-6:3-2:5-16;10:15-12:14-13:11-17;";
- my @balances = split(';', $balArray);
- print @balances;
- my @randBal;
- while (@balances) {
- push(@randBal, splice(@balances, rand @balances, 1));
- }
- print @randBal;
- my @teams = split('-', $randBal[0]);
- print @teams;
- my $singlePos = 0;
- if ($numberPlayers % 2){
- $singlePos = pop(@teams);
- }
- print @teams;
- my @randTeams;
- while (@teams) {
- push(@randTeams, splice(@teams, rand @teams, 1));
- }
- foreach my $teamPos (@randTeams){
- print '-' . $teamPos .'-';
- if(index($teamPos, ':') != -1){
- push(@balPos, split(':', $teamPos));
- }else{
- push(@balPos, ($teamPos))
- }
- }
- print @balPos;
- unless($singlePos == 0){
- push(@balPos, ($singlePos));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement