The UEFA Champions League is the uber league for European club football¹, combining the best teams of different associations.

Now some conspiracy theories came up after the last drawings for the next round, because an UEFA official predicted the exact pairings at a test screening.

ATM a German news paper tried to calculate the likelihood for this to happen and said that the rules are too complicated for a mathematical approach and a computer program counted 5463 possible pairings

from http://www.uefa.com/newsfiles/19071.pdf

First knockout round 6.07 The first knock-out round pairings are determined by means of a d +raw. 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 t +he 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.

Now I tried the same, with the following script I counted also 5463 possible pairings.

#!perl use strict; use warnings; my @first = qw(Paris Schalke Malaga Dortmund Turin Bayern Barcelon +a 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 grou +pstage? return if $first ~~ @england and $second ~~ @england; return if $first ~~ @italy and $second ~~ @italy; return if $first ~~ @spain and $second ~~ @spain; return 1; }

It's the first time that I used the smart match as an in-operator in arrays, it's not the most efficient way but it clarifies the program logic

I came pretty far with pencil and paper, but the edge cases for teams from the same qualification group take too much effort...

UPDATE:

Anyway I'm not sure that all possible combinations have the same probability to happen...

Cheers Rolf

¹) association football somewhere also known as soccer


In reply to Possible pairings for first knockout round of UEFA champions league by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.