function [plain,ssd] = condorcet(election) % [plain,ssd] = condorcet(election): Plain and SSD Condorcet winners % $election$: matrix or name of file containing pairwise matrix or ballots % -- same conventions as $tallies$, below % $plain$: winners from Plain Condorcet voting % $ssd$: winners from SSD Condorcet voting (BONUS) % note: when there are ties, *all* possible answers are returned % ----- << your code for condorcet goes here >> ----- function [i,j,v] = alldefeats(pwm) % [i,j,v] = alldefeats(pwm): defeats in ascending order in pairwise matrix % $pwm$: pairwise matrix % $i,j,v$: $k$-th defeat is $i(k)$ over $j(k)$ with magnitude $v(k)$; % $v$ is sorted in ascending order % ----- << your code for alldefeats goes here >> ----- function t = issubset(a,b) % t = issubset(a,b): "$a$ is a subset of $b$?" % ----- << your code for issubset goes here >> ----- % function pwm = tallies(election) % pwm = tallies(election): pairwise matrix specified by election$ % $election$: matrix or name of file containing pairwise matrix or ballots % + if $election$ is an array of numbers, it is a pairwise matrix % + if $election$ is a string vector, has length $>2$, and has second % character neither $'>'$ nor $'='$, it is the name of a file: % + if the file contains numbers, it holds a pairwise matrix % + otherwise, the $i$-th line holds the ballot of the $i$-th voter % + otherwise, $election$ is a 2-D string matrix where % the $i$-th row is the ballot of the $i$-th voter % % the format of a single ballot is the same as for $tally$, below; % each ballot is assumed to have the same number of candidates % ----- << your code for tallies goes here >> ----- function pwm = tally(ballot): pairwise matrix for single ballot $ballot$ % pwm = tally(ballot): pairwise matrix for single ballot $ballot$ % $ballot$: a string vector of holding an ordered sequence of candidates % + candidates are represented by consecutive letters of the alphabet, % starting at $'a'$, and ignoring case ($'a'$ and $'A'$ are the same) % + $ballot(1:2:end)$ is the list of candidates % $ $ballot(2:2:end)$ holds comparisons $'>'$ and/or $'='$ % % example: $tally('d>c=e=b>a')$ % ----- << your code for tally goes here >> ----- function top = topmost(pwm) % top = topmost(pwm): innermost unbeaten sets for pairwise matrix $pwm$ % ----- << BONUS: your code for topmost goes here >> ----- function list = unbeaten(pwm,list): smallest unbeaten set containing $list$ % list = unbeaten(pwm,list): smallest unbeaten set containing $list$ % $pwm$: pairwise matrix % note: $list$ is both a return variable and a parameter % ----- << BONUS: your code for unbeaten goes here >> -----