Created
December 20, 2012 13:59
-
-
Save joriki/4345452 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment