% Script C2CVL1
% Tabulates the number of ways that the Dems can win in 2016 given 19
% competitive states. The number of possible Electoral College ties is also
% reported.
% Votes for the competitive states...
FL=29;PA=20;OH=18;GA=16;MI=16;NC=15;VA=13;IN=11;AZ=11;MN=10;
MO=10;WI=10;CO=9;SC=9;OR=7;NV=6;IA=6;NM=5;NH=4;
% Counters...
tie_count =0;
win_count = 0;
% Nineteen nested loops that step through all the possibilities.
for t1 = 0:FL:FL % t1 = FL votes for Dems
for t2 = 0:PA:PA % t2 = PA votes for Dems
for t3 = 0:OH:OH % t3 = OH votes for Dems
for t4 = 0:GA:GA % t4 = GA votes for Dems
for t5 = 0:MI:MI % t5 = MI votes for Dems
for t6 = 0:NC:NC % t6 = NC votes for Dems
for t7 = 0:VA:VA % t7 = VA votes for Dems
for t8 = 0:IN:IN % t8 = IN votes for Dems
for t9 = 0:AZ:AZ % t9 = AZ votes for Dems
for t10 = 0:MN:MN % t10 = MN votes for Dems
for t11 = 0:MO:MO % t11 = MO votes for Dems
for t12 = 0:WI:WI % t12 = WI votes for Dems
for t13 = 0:CO:CO % t13 = CO votes for Dems
for t14 = 0:SC:SC % t14 = SC votes for Dems
for t15 = 0:OR:OR % t15 = OR votes for Dems
for t16 = 0:NV:NV % t16 = NV votes for Dems
for t17 = 0:IA:IA % t17 = IA votes for Dems
for t18 = 0:NM:NM % t18 = NM votes for Dems
for t19 = 0:NH:NH % t19 = NH votes for Dems
D = 179+t1+t2+t3+t4+t5+t6+t7+t8+t9+t10+t11+...
t12+t13+t14+t15+t16+t17+t18+t19;
if D==269
tie_count = tie_count+1;
elseif D>=270
win_count = win_count+1;
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
fprintf('\nCVL1: ties = %6d wins = %6d \n',tie_count,win_count)