public
Created

Calculate the number of possible draws in the draw for the round of 16 in the 2012–13 UEFA Champions League; see http://math.stackexchange.com/questions/262629.

  • Download Gist
Question262629.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
public class Question262629 {
final static String [] [] associations =
{
{"FRA","GER","SPA","GER","ITA","GER","SPA","ENG"},
{"POR","ENG","ITA","SPA","UKR","SPA","SCO","TUR"}
};
 
static int count;
static boolean [] paired = new boolean [8];
 
public static void main (String [] args) {
recurse (0);
System.out.println (count);
}
 
static void recurse (int n) {
if (n == 8)
count++;
else
for (int i = 0;i < 8;i++)
if (i != n && !paired [i] && !associations [0] [n].equals (associations [1] [i])) {
paired [i] = true;
recurse (n + 1);
paired [i] = false;
}
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.