Counting Towards Infinity


I have nothing but sympathy for the election workers in Florda. I also seriously want a hand-recount. Both of these attitudes are strongly informed by personal experience. Let me explain.

Freshman year in college, I was one of those crazy types who was into student government. Don't ask me how I wound up that way; it was a mixture of running with a progressive crowd, youthful idiocy, and pure random happenstance. In any case, the time came, in mid-spring, to hold a campus-wide election for the President and Vice-President of the Undergraduate Council.

This was kind of a first. In the past, the Council had always elected its own officers; thanks to a bizzare set of steps and missteps, it was decided that the student body as a whole would elect the Council's presidng officers, but wouldn't invest them with any authority beyond that conferred by holding the gavel. In short, a recipe for post-election disaster. In this case, though, we got disaster as part of the elections, too.

One of the messes that had led to the public uprising that created popular elections had been a series of ballot-box-stuffing scandals that had beset previous Councils, including some especially embarassing incidents in which Council members attempted to thwart an anti-UC ballot iniative by simply throwing out some of the ballots from the boxes they were responsible for (voting was, at that time, conducted in dining halls around campus).

In response, and partly to jump on this new "computer thingy" bandwagon, the UC had commissioned a voting program to hold the elections for its representatives. Written by a fairly zealous freshman, the program reused the UI from his successful sectioning program (used to sort students into the discussion sections of large lecture courses), stapled to a hastily-whipped-up back end that did the tabulation.

Unfortuantely, when it came time for the campus-wide elections, we realized that the existing program wouldn't work. For one thing, it was wildly insecure, as in, it didn't even try. Section assignments, well, nobody really cares about the breach of privacy involved in finding out that Monday at 5 was your first choice, but Thursday at 4 was your second choice. In the massive scruitiny and debate surrounding these first-ever popular elections, though, everyone was all of a sudden expecting that this election be "confidential," and "fair," and "trustworthy."

Even more seriously, the program simply wasn't going to work for the campus-wide elections. To elect its represntatives, the UC uses the Hare Proportional voting system, a complicated system for electing multiple delegates that requires rank-ordered preferences and periodically reweights every extant ballot. To elect President and Vice-President, the newly-amended UC Constitution specifically required the Single Transferrable Vote system, a slightly less convoluted scheme that also uses rank-ordered preferences, but manhandles the ballots in a marginally different way. Oh, and also, the old program had no concept of multiple elections: in order to use it, we'd have had to require people to vote twice, using two completely separate processes.

Rewriting was out of the question. The program's author wasn't interested in the job, and everyone else who looked at the code was afraid to touch it. There were sections in it that -- we are not making this up -- read like:

candidates[candidate]->candidate = candidate;

This is basically where my role in the whole sad story begins. Being young and naive, I'd volunteered to be on the Election Commission overseeing the voting. There were three of us from the UC, and three students at large, and it turned out that I was the only one who knew anything about computers. Suddenly, I was the point man, off to go talk to the Computer Society about commissioning a new voting program. Mostly I was a go-between in those first few days, reporting back on how much money they wanted and so forth. Amazingly, we convinced the UC to pony up the bucks: enough to bring the Computer Society safely away from the fiscal insolvency that was a recurring problem for it, and also to buy a computer that could be physically secured to serve as the vote-server. People would make secure connections to the box and vote in encrypted sessions. No member of the Election Commission would retain the entire password for the server; the machine would be physically located in a locked office owned by the University's Computer Services people, who were pretty generally acknowledged to be real tightasses about secuirty issues.

And the program? Gleaming, state-of-the-art software! A scripting-controlled client app would negotiate a secure session, then hand over control to a graphical curses UI that would let you read position papers, respond to survey questions, and rank candidates in an arbitrary number of "elections." A back-end database, updated with the latest info from the Registrar, would confirm that each student could vote only once. And a shiny new modular C++ vote-counter would allow you to plug in your choice of algorithms before feeding back to you the beautifully-formatted tabulation of votse.

Such was the plan.

The first thing to go wrong was that, come twelve midnight on the first day of voting, the program simply refused to work. Nobody could log on to vote. Of course, there were candidates all over campus, trying to pull stupid student-government publicity stunts by being the first to vote. The crack technical team assembled, looked at stuff, discovered that yes, the server wasn't accepting voting logins even though the test-run had been successful. About half an hour later, someone figured out the problem -- file permissions on one of the election data files, I think -- and voting commenced for real. The Election Commission -- already sick of the election, thanks to the 2000 signatures we'd had to verify to certify candidates' nominations for office -- met, agreed to extend the tail end of the election, three days in the future, by half an hour, and went home.

The next day, while adjudicating a dispute between one candidate and his former best friend, who'd accused him of putting up campaign signs too close to a polling place (with electronic voting, this now meant any network-accessible computer), we learned that some people still couldn't vote. Ha ha, hee, it looked like the Registrar's database of eligible student voters wasn't so accurate. We went over, had them re-run the query, this time being more careful about including the international students. A quick patch of the database on the server, and all was well.

Until the day after, when it seemed that some students -- those just returned from leaves of absence, I think -- couldn't vote. Ho hum, we knew how to deal with this one. The Computer Society people went over to the Registrar's, got a disk with the re-refined query output. Someone on the Election Commission had to meet them at the computer room to let them in, so down I went. And I watched as the crack programming team proceeded to overwrite the list of candidates with the list of eligible voters.

Whoops! Slippery little devil, ain't it?

We pulled the network plug from the wall and considered the situation. No backup list of candidates, and people were going to start noticing, soon. We retyped the file by hand. We had no clue about the order of candidates, so people logging in after that point would see a differently sorted list, but since we'd gone with a random order for the first cut, we figured it didn't make much difference.

The day after that, when the election ended at 5:30 PM, we gathered around for what we hoped would be a mercifully quick process. Some of us, with particular partisan leanings, were somewhat nervous about the outcome, but we kept our thoughts to ourselves. The Election Commission was split among two unspoken supporters of two major tickets -- although by the end of the election, none of us liked any of the candidates (with the exception of the bullhorn guy and a doomed sixth-party candidate) very much. In any case, being seen as impartial about the results of the election were the least of our worries. First, we needed results.

And that counting program? Well, um, ah, it wasn't ready yet. The lead programmer was still debugging a bit, the president of the Computer Society assured us. But he'd be done within the hour. We should start the process of getting to the vote files. And this was when we discovered three major problems.

First, we couldn't get at the files. There was something in the security setup that blocked us from getting the raw file over the network cable onto the tallying machine.

Second, despite many repeated promises to the contrary, the election program let you quit within recording a vote in one or both of the elections. You had to go through a fairly innvolved procesure, but it was quite possible, and in fact, some people had managed to pull it off. This made some of the ballots invalid according the file format we were using to store them. Oh, joy.

Third, there were more candidates listed in the ballots than there were in the election. When retyping the data after the overwrite, we'd misspelled one candidate's name, and dropped the middle initial from a few others. Result: separate vote tallies for "Al Gore" and "Albert Gore," as it were.

Oh, and yeah, thanks to someone's undoubtedly brilliant design insight, the ballots stored the voter's identifying information in cleartext in them. Which meant that it was unethical to actually look at any of the ballots. Oh, no, our high-minded early-in-the-night ethics told us we'd need to repair the damage without looking at the ballots.

My friends, grep is also my friend, and it should be your friend, too. While most the computer people were off trying to help their compatriot debug, a friend whose part of the system had worked flawlessly and I started monkeying with various -A and -B arguments to grep, piped and filtered in various ways. I managed to extract a count of the number of ballots missing Presidential votes, or Vice-Presidential ones, or both. And then we did some global search-and-replaces to patch up the variations in candidates' names to a consistent state. As for getting the files from point A to point B, we emailed them, in the clear, and may God have mercy on our souls.

At which point, getting into the evening, the tallying program still wasn't ready. The candidates, some in high dudgeon, had started to come round to find out the source of the delay. They had celebration parties on hold because of us; the only response we could usefully give was to pull aside members of their campaigns and suggest that they use the party supply of alcohol to try and calm down their candidtes

We demanded a hard estimate of the program's readiness from the Computer Society. Eleven, they said. Okay, we said, and we made an announcement, by email and by one EC member's booming voice, that we'd announce the results at midnight. There was grumbling, there was muttering, I scarfed some dinner

Come eleven, the program compiled, but segfaulted. Come eleven-thirty, it was still segfaulting left and right, and the programmer was poring through core dumps to figure out why. The Election Commission met again, agreed that we couldn't yet announce a winner, and agreed to not promise any more firm announcement times.

They talk about long nights of the soul. What followed was a long night of body, mind, and soul. We gave up on the counting program, although its author didn't. The president of the Computer Society, acting the part of the classic technical manager, stared at the screen blankly, tried tapping out a few things rather feebly, and then went off to go talk to the press. We called in the original vote-program's author. He looked at the situation and started coding a Perl script to compute the totals. Candidates screamed at us; we had the big people on the Election Commission deal with it. One member of the EC, looking miserable, curled up in a corner of the room and tried to sleep. Two others had to go board a bus for an off-campus event they were due at in the morning. We called the alternate, woke him from his sleep, and plodded onwards.

Towards morning, the magic Perl started producing results. The totals weren't obviously wrong -- they added up properly at the start, and the numbers moved in the right direction -- but we really couldn't tell for sure. The morning campus paper got delivered, at which point it became clear that the folks in the Computer Society had sold us up the river. Our carefully neutral statements, when mixed with their blaming us for everything that had gone wrong, led the reporter to do the obvious reporter thing and paint the Election Commission as a bunch of confused incompetents. I started to seriously consider transferring to another school. Oh, yeah, this was also the point at which the last remaining Computer Society people basically said, yeah, bye, been nice knowing you, and went home to sleep.

We got the second tally done by using grep, tail, cat, and a jot of perl. In essence, we shredded the ballot file into separate files, one per ballot, and sorted in directories based on candidate. We counted files, figured out which candidate to eliminate, struck their name from every ballot, and resorted into directories. The final numbers matched those from the first count, which in turn almost matched those from the election. I did some additions and subtractions, and managed to persuade everyone else in the room that the missing ballots exactly matched the number I'd computed for those ballots missing one or both parts of the election. We checked the write-ins -- who we'd completely ignored up to this point -- and convinced ourselves that the write-ins were numerically too few to have upset the (slightly fragile) STV algorithm at any stage. Then we felt hope, that maybe there might not be a lynch mob waiting for us outside the door.

In fact, there was no one at all there. It was early Saturday morning, one of the most beautiful mornings I can remember, dewy and bright, cool but warming in the sun. I was absurdly tired, and depressed, as stressed as I've ever been; I think the others were basically in the same state. We talked through the election, convinced ourselves that the count was accurate and that there hadn't been any fraud of the sort we'd ever have a chance of detecting, called the candidates, and went to sleep. The election was counted by two sets of Perl scripts written on the spot, with hand-tailoring by half a dozen people, all of whom were alone at the computer at some point or another. We did what we could; don't blame us for it. Have sympathy on the poor election worker; don't bring down your own election stresses on their heads.