Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
See which triplets of candidates were most frequent in the WPSE moderator election
<?php
$ballots = array(
array(1, 2, 3),
array(2, 4, 1),
array(5, 1, 4),
array(4, 2, 5),
array(1, 2, 4),
array(5, 4, 2),
array(6, 4, 5),
array(4, 1, 5),
array(5, 6, 4),
array(2, 3, 4),
array(4, 5, 2),
array(1, 4, 2),
array(4, 6, 2),
array(4, 2, 5),
array(4, 2, 6),
array(4, 5, 3),
array(1, 2, 5),
array(4, 5, 1),
array(5, 3, 2),
array(2, 5, 4),
array(4, 5, 1),
array(4, 1, 2),
array(4, 1, 3),
array(2, 1, 4),
array(4, 2, 5),
array(2, 4, 1),
array(4, 2, 1),
array(4, 2, 1),
array(4, 2, 1),
array(1, 5, 4),
array(5, 2, 3),
array(5, 2, 3),
array(4, 5, 1),
array(2, 4, 1),
array(4, 2, 3),
array(2, 3, 1),
array(5, 1, 4),
array(4, 2, 1),
array(4, 2, 5),
array(2, 4, 1),
array(4, 3, 1),
array(2, 1, 4),
array(6, 2, 5),
array(4, 2, 5),
array(4, 3, 1),
array(5, 2, 3),
array(3, 2, 1),
array(2, 5, 4),
array(1, 5, 2),
array(5, 1, 2),
array(4, 2, 1),
array(1, 2, 4),
array(4, 1, 2),
array(6, 4, 5),
array(6, 2, 1),
array(3, 2, 4),
array(4, 3, 1),
array(3, 6, 5),
array(4, 2, 3),
);
$voteGroups = array();
foreach ( $ballots as $ballot ) {
sort( $ballot );
$voteGroups[] = implode( '', $ballot );
}
$voteGroupCounts = array_count_values( $voteGroups );
asort( $voteGroupCounts );
foreach ( $voteGroupCounts as $voteGroup => $count ) {
printf( "%s: %d\n", $voteGroup, $count );
}
@janfabry

This comment has been minimized.

Copy link
Owner Author

commented Mar 30, 2011

Output:

256: 1
126: 1
356: 1
345: 1
246: 2
125: 3
456: 3
123: 3
134: 4
235: 4
234: 4
145: 7
245: 9
124: 16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.