So my task is to score all the possible rankings of the 14 SEC football teams and find the best one, using who won in head-to-head games as the sole criterion (so not factoring in strength of schedule or homefield advantage yet).
RandomSample[Range[14]]
gives me one random ranking of the 14 teams, then I score that ranking by seeing how many wins and losses it actually predicted. For example, if "1" represents Missouri (miss) and "3" represents Georgia (ga), then if the generated ranking has 1 listed before 3, that ranking gets +1 to its ranking score, since Missouri beat Georgia this season. If 3 is listed before 1, the ranking score receives a -1 to its score, for incorrectly ranking those teams with respect to each other. And so on for every head-to-head SEC match up from last year.
Once I can correctly score one ranking, I would use Permutations[RandomSample[Range[14]]]
and apply the scoring algorithm to all the permutations of a list of 14, and select the list (ranking) with the max ranking score (k).
My main issue right now is comparing the positions of teams in the rankings. In the code, k is the ranking score and one test for Missouri being listed before Georgia is listed at the bottom, with the output below it. However {{7}} cannot be compared to {{5}} as in 7 > 5, and that's my problem.
Here's the code:
list1 = RandomSample[Range[14]]
(* Out: {11, 6, 8, 13, 3, 9, 1, 4, 5, 12, 7, 14, 10, 2} *)
miss = Position[list1, 1]];
sc = Position[list1, 2];
ga = Position[list1, 3]];
vandy = Position[list1, 4];
fl = Position[list1, 5];
tenn = Position[list1, 6];
kent = Position[list1, 7];
aub = Position[list1, 8];
bama = Position[list1, 9];
lsu = Position[list1, 10];
tam = Position[list1, 11];
missst = Position[list1, 12];
olemiss = Position[list1, 13];
ark = Position[list1, 14];
k = 0;
If[miss > ga, k++, k--]
(* Output: If[{{7}} > {{5}}, k++, k--] *)
First@First@{{7}} == 7
or{{7}}[[1, 1]] == 7
. But perhaps you should create a function to tell you what team won:whoWon[team1_,team2_,{{rank1_}},{{rank2_}}]:= ..
this will take care of the issue with{{...}}
as well. $\endgroup$