Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-19 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found