|
Boost : |
From: Joel (joel_at_[hidden])
Date: 2005-04-11 15:45:55
Hi,
Thanks to Kalin who did the initial tallies and
Jason Hise who wrote the IRV tallying program, we
have a winner: Simeon Nasilowski, entry number 67.
The winning variation is 67b.
Unless there are some more objections, or if someone
can spot a bug in Jason Hise's program, we have a
winner. Attached here is Jason's IRV program and the
input file. I'd like to invite boosters to go check
it out.
Alas, it was noted that there are probably trademark problems
with the winning logo. If entry 67 gets eliminated due to
non compliance with the contest rule: "The logo must be
free of any copyright or other intellectual property claims",
then the winner will have to be 75: Zoltan "cad" Juhasz,
who placed second in the tallies.
Regards,
-- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
#include <string>
#include <vector>
#include <list>
#include <map>
#include <iostream>
using namespace std;
int main ( )
{
string s;
list < string > vote;
vector < list < string > > votes;
map < string, size_t > candidates;
while ( true )
{
getline ( cin, s );
if ( cin.eof ( ) )
{
if ( !vote.empty ( ) ) votes.push_back ( vote );
break;
}
if ( s == "vote:" )
{
if ( !vote.empty ( ) )
{
votes.push_back ( vote );
vote.clear ( );
}
}
else
{
candidates.insert ( map < string, size_t >::value_type ( s, 0 ) );
vote.push_back ( s );
}
}
bool winner = false;
size_t min_votes;
map < string, size_t >::iterator c_iter, c_next;
vector < list < string > >::iterator vl_iter;
while ( !winner )
{
c_iter = candidates.begin ( );
while ( c_iter != candidates.end ( ) )
{
cout << "clearing votes for " << c_iter->first << endl;
c_iter->second = 0;
++c_iter;
}
vl_iter = votes.begin ( );
while ( vl_iter != votes.end ( ) )
{
list < string >::iterator v_iter ( vl_iter->begin ( ) );
while ( v_iter != vl_iter->end ( ) )
{
c_iter = candidates.find ( *v_iter );
if ( c_iter != candidates.end ( ) )
{
++( c_iter->second );
break;
}
++v_iter;
}
++vl_iter;
}
c_iter = candidates.begin ( );
min_votes = c_iter->second;
winner = true;
while ( c_iter != candidates.end ( ) )
{
cout << c_iter->first << " has a total of " << c_iter->second << " votes" << endl;
if ( c_iter->second != min_votes )
{
winner = false;
}
if ( c_iter->second < min_votes )
{
min_votes = c_iter->second;
}
++c_iter;
}
if ( winner )
{
if ( candidates.size ( ) > 1 )
{
cout << endl << "TIE, WINNERS WERE:" << endl;
}
else
{
cout << endl << "WINNER:" << endl;
}
}
c_iter = candidates.begin ( );
while ( c_iter != candidates.end ( ) )
{
c_next = c_iter;
++c_next;
if ( winner )
{
cout << c_iter->first << endl;
}
else if ( c_iter->second == min_votes )
{
cout << c_iter->first << " has been removed from the running" << endl;
candidates.erase ( c_iter );
}
c_iter = c_next;
}
}
return 0;
}
vote:
87
39
50
67
74
vote:
87
39
50
67
74
vote:
75
92
98
52
67
vote:
61
98
92
21
29
vote:
92
38
18
39
67
vote:
50
61
86
95
21
vote:
37
37
37
37
37
vote:
38
39
75
1
44
vote:
67
83
75
39
88
vote:
18
60
67
52
75
vote:
83
52
67
68
18
vote:
67
17
21
83
92
vote:
50
vote:
50
50
7
88
24
vote:
83
38
75
5
17
vote:
83
38
75
5
17
vote:
67
92
69
74
20
vote:
50
70
27
38
49
vote:
25
68
43
17
69
vote:
38
67
52
75
83
vote:
38
39
50
29
4
vote:
50
95
85
76
51
vote:
1
31
21
vote:
68
39
17
46
85
vote:
68
67
68
68
75
vote:
92
39
27
86
vote:
28
67
39
75
54
vote:
67
39
38
17
6
vote:
50
36
75
60
99
vote:
67
vote:
52
75
50
83
vote:
50
50
83
83
75
vote:
39
38
46
43
54
vote:
60
20
67
29
18
vote:
69
68
38
60
19
vote:
20
85
50
92
97
vote:
75
75
39
38
1
vote:
67
67
68
75
75
vote:
68
83
20
38
67
vote:
38
67
68
69
20
vote:
39
75
68
92
83
vote:
18
75
29
1
vote:
0
75
75
38
1
vote:
83
68
38
75
23
vote:
50
58
63
40
53
vote:
91
56
57
85
88
vote:
39
6
3
32
98
vote:
50
85
98
91
93
vote:
50
75
81
38
97
vote:
3
50
88
75
99
vote:
75
20
39
60
83
vote:
39
60
4
67
83
vote:
18
67
68
83
43
vote:
50
50
51
58
76
vote:
68
83
95
85
21
vote:
50
50
50
50
50
vote:
20
92
71
33
5
vote:
2
68
68
68
2
vote:
75
67
39
83
29
vote:
42
6
46
44
20
vote:
20
86
25
36
18
vote:
38
5
2
92
29
vote:
46
17
66
85
27
vote:
61
50
25
76
60
vote:
60
42
92
27
18
vote:
67
67
43
46
43
vote:
38
38
77
76
10
vote:
3
67
52
38
1
vote:
20
88
97
18
48
vote:
97
6
92
50
57
vote:
3
5
67
88
50
vote:
75
68
85
98
60
vote:
50
50
67
20
75
vote:
39
20
92
67
99
vote:
85
75
67
17
60
vote:
2
19
67
75
18
vote:
75
68
12
38
83
vote:
96
85
92
83
88
vote:
75
52
60
47
50
vote:
83
67
75
20
17
vote:
38
5
50
67
39
vote:
92
69
48
68
20
vote:
86
23
20
18
17
vote:
39
38
5
75
19
vote:
92
19
29
75
77
vote:
68
67
85
46
38
vote:
3
17
18
68
10
vote:
50
63
68
84
96
vote:
25
67
6
99
68
vote:
38
39
38
39
67
vote:
5
18
20
3
4
vote:
67
67
20
20
75
vote:
83
67
39
5
29
vote:
83
50
6
38
75
vote:
21
15
29
10
67
vote:
61
20
67
50
92
vote:
17
36
5
33
42
vote:
29
29
30
68
75
vote:
87
87
87
62
52
vote:
38
39
75
20
92
vote:
67
83
92
50
vote:
21
29
20
67
92
vote:
13
5
46
20
42
vote:
19
28
33
39
71
vote:
23
39
39
5
6
vote:
19
7
38
29
99
vote:
60
39
50
48
25
vote:
67
50
52
75
83
vote:
46
20
39
75
92
vote:
39
75
50
60
68
vote:
51
17
38
49
75
vote:
61
39
20
46
97
vote:
85
68
83
75
67
vote:
1
vote:
50
75
20
92
87
vote:
75
52
68
67
83
vote:
52
28
75
83
67
vote:
3
6
18
47
5
vote:
67
67
87
49
63
vote:
97
50
68
6
29
vote:
99
75
20
1
vote:
21
21
68
85
99
vote:
38
75
5
17
20
vote:
91
52
83
29
94
vote:
92
75
38
60
52
vote:
67
83
49
21
38
vote:
67
83
74
38
3
vote:
18
61
92
5
39
vote:
92
83
68
6
67
vote:
5
20
19
60
92
vote:
75
75
75
38
97
vote:
39
68
83
75
17
vote:
67
50
75
92
38
vote:
68
83
5
67
23
vote:
39
3
17
43
67
vote:
61
92
19
95
50
vote:
74
56
57
58
59
vote:
38
5
83
6
67
vote:
50
92
39
69
39
vote:
67
7
75
20
68
vote:
67
38
92
75
46
vote:
50
vote:
85
69
68
101
92
vote:
85
67
43
75
5
vote:
67
83
29
1
39
vote:
18
23
68
68
67
vote:
75
60
21
38
67
vote:
50
50
38
92
81
vote:
42
98
20
23
85
vote:
30
30
69
85
2
vote:
38
92
5
24
67
vote:
52
75
83
68
29
vote:
75
52
75
52
52
vote:
68
52
85
80
22
vote:
68
67
17
51
85
vote:
68
75
83
38
1
vote:
50
50
10
88
23
vote:
52
75
50
83
vote:
50
75
97
61
83
vote:
62
43
46
19
5
vote:
85
31
38
38
38
vote:
83
38
75
28
20
vote:
43
85
7
37
97
vote:
75
60
67
20
49
vote:
75
68
39
21
98
vote:
85
68
23
89
31
vote:
20
3
5
17
91
vote:
48
83
21
67
75
vote:
61
60
20
75
68
vote:
50
97
88
46
75
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk