First knockout round 6.07 The first knock-out round pairings are determined by means of a draw. The first knockout round is played under the cup (knock-out) system, on a home- and-away basis (two legs). The UEFA administration ensures that the following principles are respected. a) Clubs from the same association must not be drawn against each other. b) The winners and runners-up of the same group must not be drawn against each other. c) The group-winners must not be drawn against each other. d) The runners-up must not be drawn against each other. e) The runners-up must play the first leg at home. #### #!perl use strict; use warnings; my @first = qw(Paris Schalke Malaga Dortmund Turin Bayern Barcelona ManU); my @second= qw(Porto Arsenal Mailand Madrid Donezk Valencia Celtic Galatasaray); my @england = qw(ManU Arsenal); my @italy = qw(Turin Mailand); my @spain = qw(Barcelona Malaga Valencia Madrid); my @drawn; my %count_hash; my $count; draw_match(); print $count,"\n", scalar keys %count_hash; sub draw_match { my $first = $first[scalar @drawn]; unless ( $first) { print "@drawn\n"; $count++; $count_hash{"@drawn"}=1; return; } for my $second (@second) { next if $second ~~ @drawn; next if not allowed($first,$second); push @drawn, $second; draw_match(); pop @drawn; } } sub allowed { my ($first,$second)=@_; return if $second eq $second[scalar @drawn]; # same groupstage? return if $first ~~ @england and $second ~~ @england; return if $first ~~ @italy and $second ~~ @italy; return if $first ~~ @spain and $second ~~ @spain; return 1; }