Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Obfuscated Vote Counting Contest

michael posted more than 9 years ago | from the some-votes-are-more-equal-than-others dept.

Programming 223

Daniel Horn writes "In a flash of inspiration coming from the Obfuscated C code contest and the current E-voting scandals, I wondered if there shouldn't be a similar code obfuscation contest based on obfuscating voting results, that is, C code that appears correct but does the wrong thing when counting votes. Submit your obfuscated vote-counting code now, and the two winners will be selected on November 2 and will receive a free Vega Strike CD. Obviously incorrect code, however, is not welcome."

cancel ×

223 comments

Sorry! There are no comments related to the filter you selected.

I WIN! (5, Funny)

AmigaAvenger (210519) | more than 9 years ago | (#10544323)

Quick, someone post some of the Diebold voting machine code, you certainly will have a winner in there!

Re:I WIN! (2, Funny)

qube99 (652571) | more than 9 years ago | (#10544343)

10 print "KERRY WINS!" 20 goto 10

Answer me this. (-1)

Anonymous Coward | more than 9 years ago | (#10544535)

Just what the heck is a "dickless workstation"?

Actually... (1)

Allen Zadr (767458) | more than 9 years ago | (#10544934)

I know - I'm ruining everything but, really ... they are looking for 'C' not basic.

while(printf("KERRY WINS!\n"));

That's what you meant to say, right?

Re:I WIN! (4, Funny)

anonymous cowherd (m (783253) | more than 9 years ago | (#10544344)

Did anyone notice the irony in the fact that the email address for submissions is dyebold@gmail.com? LOL.

Re:I WIN! (-1, Flamebait)

Anonymous Coward | more than 9 years ago | (#10544595)

Do you fucking know what irony is, you twit? Seriously.

Re:I WIN! (0)

Anonymous Coward | more than 9 years ago | (#10544798)

Yeah, it's like goldy and bronzy, only made of iron!

Re:I WIN! (1, Funny)

Anonymous Coward | more than 9 years ago | (#10544501)

#include <stdio.h>

enum {
BUSH;
KERRY;
NADER;
YADA_YADA;
} Candidates;

int main (int argc, char **argv)
{
FILE *fd;
int c;
int bush = 0, kerry = 0, nader = 0, yada_yada = 0;

fd = fopen("ballots.str");
while ((c = getc(fd)) != EOF) {
switch (c) {
case BUSH:
bush += 1;
break;
case KERRY:
kerry += 1;
break;
case NADER:
nader += 1;
break;
case YADA_YADA:
yada_yada += 1;
break;
}
}

printf("And the winner is BUSH!\n", w);

return 127;
}

Re:I WIN! (4, Funny)

Phillup (317168) | more than 9 years ago | (#10544707)

You gotta do it right (like... FAR right ;-))
switch (c) {
case YADA_YADA:
yada_yada += 1;
case NADER:
nader += 1;
case KERRY:
kerry += 1;
case BUSH:
bush += 1;
}
That will more likely pass the "first glance" test... and give the big guys the numbers they "deserve".

And, I'm sure Bush would believe he really does have that much more "support" from "his" citizens than Kerry.

Re:I WIN! (0)

SamBeckett (96685) | more than 9 years ago | (#10544758)

I believe you sir are confused. Bush would only have the majority of votes in your statement, if he did, in fact, have the majority to begin with.. If he were at the top of the switch statement, then your assertions would be correct.

Re:I WIN! (0)

Anonymous Coward | more than 9 years ago | (#10544874)

It's C/C++; cases fall through. Read it again.

Re:I WIN! (0)

vikingpower (768921) | more than 9 years ago | (#10544984)

Yup. No DEFAULT case. Frequent beginner's error. This would most likely go unnoticed, as

1) this code looks "serious", "well-done" ( the code seems to do its job, nothing more and nothing less, at first glance )

2) many coders, even advanced / experienced, do not always bother to write DEFAULT cases.

Re:I WIN! (2, Informative)

Fjornir (516960) | more than 9 years ago | (#10545067)

You're missing something more important than a default case.

Re:I WIN! (4, Informative)

00420 (706558) | more than 9 years ago | (#10545126)

It has nothing to do with default case. It has to do with the lack of breaks.

Read it again. A vote for kerry means both kerry and bush get a vote. A vote for nader means nader kerry and bush get a vote.

Re:I WIN! (1)

simcop2387 (703011) | more than 9 years ago | (#10545166)

this has nothing to do with default cases
this has to do with no breaks this causes the code to continue on to the next case even though you think it might not, this makes a vote for kerry or anyone else also count for bush

Re:I WIN! (1)

keesh (202812) | more than 9 years ago | (#10545197)

Heh. See, idiots like you who think they know how to program but don't are the reason stuff like this is possible.

You Think You're Funny (1)

michael.teter (811516) | more than 9 years ago | (#10545055)

It's interesting how much loud anti-Bush crap like yours there is, and yet, when it comes time to vote, half of America wants him.

I personally think it's a pretty good thing that half of America leans left, and the other half leans right. Or more accurately, half of America is sitting right in the middle, and the other two quarters are on the fringes.

Loud lefties are typically in that 25% left. Religious Righters are typically in the 25% right. The rest of us are in the middle. We like some left ideas, and some right ideas.

But it's nice to see Slashdot mods stick to their convictions (left fringe, of course).

Re:You Think You're Funny (0)

Anonymous Coward | more than 9 years ago | (#10545139)

read the code you stupid twit.

Damn (4, Funny)

antifoidulus (807088) | more than 9 years ago | (#10544325)

I was going to submit the Diebold code till I read:Obviously incorrect code, however, is not welcome.

ERROR IN ORIGINAL POST (0)

Anonymous Coward | more than 9 years ago | (#10544717)

The "Submit your obfuscated vote-counting code now" link should read: Submit your obfuscated vote-counting code to the Diebold "Defending our right to count your vote however we damn well please" competition. that is all

Gah (1, Funny)

Xpilot (117961) | more than 9 years ago | (#10544327)

Is this another one of GWB's evil plots to get another fake victory? I wouldn't want to release such code out in the open. It could be used for evil...evil!

not GWB... (1)

_defiant_ (120560) | more than 9 years ago | (#10544561)

GWB doesn't have any evil plots this election... all the scheming is done by Karl Rove.

At least, that is what some would have me think.

Powered by Windows? (1)

The Islamic Fundamen (728413) | more than 9 years ago | (#10544330)

Hmm, I could hav sworn I saw a "Powered by Windows ME" on a Diebold once....

Re:Powered by Windows? (4, Interesting)

psetzer (714543) | more than 9 years ago | (#10544556)

Well, you must have misread. They use Windows CE. I shit you not.

I Wonder (1)

MarkVVV (740454) | more than 9 years ago | (#10544331)

who would submit code before testing...if so, the person in question would be so stupid he/she shouldn't be coding at all.

And while you're hacking away... (0, Troll)

Machine9 (627913) | more than 9 years ago | (#10544332)

...please don't spend any time thinking about how you could do anything that might lead to a DECENT candidate for presidency being available next around.

In fact, just forget to vote alltogether, not like your vote counts, right? ;)

Re:And while you're hacking away... (2, Funny)

Tackhead (54550) | more than 9 years ago | (#10544818)

> ...please don't spend any time thinking about how you could do anything that might lead to a DECENT candidate for presidency being available next around.
>
> In fact, just forget to vote alltogether, not like your vote counts, right? ;)

I dunno, I'd think that being able to hack the best-hidden trapdoor into the voting system would make your vote count for quite a bit!

STALLMAN-BALMER 2008!

Hiding... (5, Interesting)

Anonymous Coward | more than 9 years ago | (#10544351)

If I were doing this, I would hide the date analysis and vote rigging in another part of the program. For example, the code used to handle the screen and menus, or the network stack.
Then, you could obfuscate a call to jump the program pointer to that part of memory directly, run a tiny bit of code that appears to deal with graphics, but does something else when called with the correct offset.
The devious would be scattered about, rather than in one single vote counting function.

Re:Hiding... (2, Interesting)

Starji (578920) | more than 9 years ago | (#10544569)

I wish I had more experience with code obfuscation, then I might actually submit something. Probably the poor man's way of doing this might be to copy their vote.c and then have some sort of on-the-fly vote redirector to favor one candidate. Compile it to assembly then copy the relavant portion back to the origional source code and do an inline assembly replacing the origional c code. if the assembly is especially long, it's likely nobody will be able to decode it anyway since almost nobody knows assembly anymore. Add a little more fun with some #defines at the top and you have something that's fairly obfuscated (to an untrained eye) and does what you want with the host language remaining the same. Don't know what the rules are on inline assembly though....

Re:Hiding... (2, Interesting)

Lehk228 (705449) | more than 9 years ago | (#10544660)

I just changed the memory location to output Kerrys vote count from, since the code increments array['K'] i just output array['k'], now kerry gets 0 votes and "other" gets all of his votes instead. I chose Kerry to target with the code because 'k' and 'K' are much more similar than 'b' and 'B' or 'N' and 'n'.

Re:Hiding... (3, Interesting)

globalar (669767) | more than 9 years ago | (#10544624)

In that same vein, I would use code which has somewhat unpredicatable and incremental behavior. It is much harder to detect code which alters data seemingly at random, and sometimes not at all.

Changing a small amount of data with minimal condition at pseudorandom intervals is practically an intentional bug. Of course, if I can expect a certain threshold of data, I might be able to add a statistical leaning into the program that favors a particular outcome. Of course, this is the point of the contest. The point is, blind trust is no trust at all.

Way way back .... (1)

A nonymous Coward (7548) | more than 9 years ago | (#10544705)

Way back in my salad days, 1970 or so, I had a FORTRAN II program which had expanded to, I think, 1600 cards or so, most of a box. Plotted some graphics on a line printer. I got tired of the program and decided to go out of style in good fashion. I don't remember any details now, and have forgotten most of the FORTRAN I ever knew. But the main entry point, equivalent of main() in C, never executed. Instead it began with some obscure subroutine which was never called by the source code, which proceeded to call other never-called subroutines, and gradually self-modified itself, so that after it had been running for a few seconds, and actually done the line printer plotting, it had converted some piece of code into a system instruction which crashed the machine. The machine was a CDC 6400. There were two of them, called A and B. B was used for some experimental time share system, and had the system instruction which was not supposed to be present on A, as the university did not feel like paying CDC for an unused instruction. But it seems that the CDC rep needed that instruction for his weekly maintenance checks, so left it permanently wired in place, rather than disconnect it at the end of each visit. So even tho I had prominently labeled the card deck to run on A only, it went ahead and crashed it.

I wonder if Diebold uses FORTRAN II ... maybe I could get a job there ...

Summary of this year's election (5, Insightful)

Dancin_Santa (265275) | more than 9 years ago | (#10544356)

enum Outcome
{
AMERICAWINS,
AMERICALOSES
}

int main()
{
bool voted = didYouVote();

Outcome o;

switch (voted)
{
case true:
o = AMERICAWINS;
case false:
o = AMERICALOSES;
}
return o;
}

Re:Summary of this year's election (2, Insightful)

fossa (212602) | more than 9 years ago | (#10544400)

AVP: No matter who wins, we lose.

Re:Summary of this year's election (4, Funny)

tomhudson (43916) | more than 9 years ago | (#10544405)

More efficient code, to avoid all the suspense. It is guaranteed to return the correct outcome every time!
#define AMERICALOSES 0x00

int main() {
return AMERICALOSES;
}

Nah (1)

TheLink (130905) | more than 9 years ago | (#10544455)

#include <AvPmovieblurbs.h>
int main() {
return AvP_WHOEVER_WINS;
}

Re:Summary of this year's election (1)

toetagger1 (795806) | more than 9 years ago | (#10544407)

Is that last line return o or return 0?

Re:Summary of this year's election (3, Insightful)

Anonymous Coward | more than 9 years ago | (#10544418)

I don't know if you're trying to encourage voting or proposing code for the contest but by leaving out the "break;" in your switch statment I think you've certainly predicted the outcome of this year's elections.

Re:Summary of this year's election (-1, Troll)

GhostseTroll (582659) | more than 9 years ago | (#10544431)

Your Bowels Cleansed

Let me ask you this...which is worse:

A. The engine on your Lexus freezes up at 160,000 miles instead of 300,000. You take a financial hit and you are forced to buy a Camry this time.

B. You start bleeding during bowel movements. You go to the doctor and get poked, prodded, X-ray'd, biopsied, etc. 3 days later you get a call for a consultation. The doctor informs you that you have advanced colon cancer at 45 years old. You have anywhere from 6 months to 5 years left to live. He tells you it's time to get your house in order because you'll be checking out soon. Chemotherapy starts today.

A friend of mine who was a science and health researcher at the University of Chicago, just died this past year of colon cancer at 42. In the midst of the prime of his life, he said goodbye, and left his wife and child behind, wondering what just hit them.

Why do you brush your teeth? Are your teeth falling out right now? For most of us, we do it so we won't need false teeth and Fixodent down the road...right? We want to be able to eat apples. Hey, I agree with that. Natural teeth are great.

But have you ever seen someone who was forced to endure a colonectomy? Someone who now will be spending the rest of their life carrying a bag around?

Incredibly, this is an area where even the staunchest MD's AGREE with us!! Can you believe it? If they knew you had the greatest colon cleanse in the world, I bet they might even refer people to you. NO, I'm not kidding...

This subject is not even up for debate. It's a proven fact. The problem is, most people are not doing anything about it. Please don't be one of them.

****WARNING***** The next section of this email contains graphic
material which may not be suitable for squeamish individuals.

Let's talk stools.

The stool tells you a lot about your colon health. If it's dark brown in color, and it sinks, and it stinks, that's not good. And don't feel bad, that's the way most people are. What you want to see is light brown color, which means it's full of fresh bile from the liver, very mild odor, and a stool that floats. We're talking low-density here folks. The more compaction you have the darker the color and the faster it sinks. Compaction is not good. Also, moving bowels should be SIMPLE. If the veins are popping out of your neck and you feel like your doing the bench press, you NEED to cleanse your colon.

When you do the cleanse, for the first few days....things are a little weird. But you know you're cleansed when you see the above good stuff happening, and you are eliminating at least 2-3 times per day.

Cleansing your colon is a 30-day process. Its also very economical at under $50. You may be very surprised at some of the benefits you will receive besides just losing 1-5 lbs of cr*p from your body and brightening your future health.

People have reported more energy, less allergies, clearing of acne, cessation of migraines, and many other results, not to mention restored regularity. When your body is void of old, poisonous toxins that are constantly being reabsorbed through the colon walls, it can begin to heal again. And when the colon walls are clean, the good nutrients from your food and supplements can be absorbed again. You will be thrilled with the results.

At this point you are either nauseated thinking about what is inside your own colon, or you're ready to do something about cleaning it out.

Want more info? Click here and I'll send it to you, including instructions on how to take it. It is private, all natural, totally safe, inexpensive, and very effective. And yes, I have taken it myself.

Currently available only in the U.S. and Canada. Seeking Distributors to meet high demand.

More Infor [goat.cx]

cmdrtaco@slashdot.org?subject=SendColonCleanseIn fo

cmdrtaco@slashdot.org?subject=PleaseRemove

Please do not 'reply' to this email as we might not see your message. Please use the links above.

Re:Summary of this year's election (1)

roman_mir (125474) | more than 9 years ago | (#10544478)

So are you trying to say that no matter if you vote or not america still loses?

You need to expand on that, if say most americans vote for the Libertarian party, does america still lose? What if it's Green?

Re:Summary of this year's election (1)

keesh (202812) | more than 9 years ago | (#10545169)

You're forgetting the millions of other people voting who don't understand any of the issues involved in the election.

Pick me, pick me! (0, Troll)

Michael's a Jerk! (668185) | more than 9 years ago | (#10544360)

int vote(Vote person){

if(person==KERRY){

printf("Voted for Kerry");
kerry++;
bush++;

}

if(vote==BUSH){

printf("Voted for Bush");
bush++;

}

}

Patent pending (5, Funny)

GrAfFiT (802657) | more than 9 years ago | (#10544387)

"C code that appears correct but does the wrong thing when counting votes"
Beware of Diebold suing you for infringing one of their patents !

hehehe free cds! (1)

DMJC-L (800240) | more than 9 years ago | (#10544393)

hehehe Daniel Horn the guy who posted is the head of the vegastrike project... good guy, I've known him for about 5 years now.

last election (0)

WhitePanther5000 (766529) | more than 9 years ago | (#10544399)

here's the code the used during the last election:

if (strcmp(canidate,"Bush"))
bushvotes += 10;
elsif (strcmp(canidate, "Nater"))
bushvotes += 1;
elsif (strcmp(canidate, "Gore"))
gorevotes = 1;

Re:last election (1, Funny)

Sv-Manowar (772313) | more than 9 years ago | (#10544404)

surely you mean if (strcmp(canidate,"Bush")) bushvotes += 100; elsif (strcmp(canidate, "Nater")) bushvotes += 10; elsif (strcmp(canidate, "Gore")) gorevotes = -100;

Re:last election (1)

thebes (663586) | more than 9 years ago | (#10544462)

surely you meant to use line breaks...

Re:last election (5, Funny)

Anonymous Coward | more than 9 years ago | (#10544550)

Surely you know that C and C++ don't give a damn if there are new lines and carriage returns in the whitespace or not.

Only newbie programmers use new lines and carriage returns.

Real programmers don't use new lines and carriage returns as it detracts from being able to glance at the whole program at once and immediately understand it's intent, purpose, and spot any bugs in a holistic fashion.

Nader not Nater (1)

masukomi (229249) | more than 9 years ago | (#10544437)

NaDer not Nater

Nater is a Basketball player, Nader is a presidnetial candidate.

Re:Nader not Nater (1)

The Islamic Fundamen (728413) | more than 9 years ago | (#10544445)

didnt you also forget a + sign somewhere?

Re:Nader not Nater (3, Funny)

OneDeeTenTee (780300) | more than 9 years ago | (#10544672)

Nater is a Basketball player, Nader is a presidnetial candidate.

And they both have the same chances of becoming president.

Re:last election (1)

JDWTopGuy (209256) | more than 9 years ago | (#10544446)

Har har. First off, you misspelled "Nader". Second, your code does not reflect the outcome of the last election, which was close. Third, they didn't use digital voting either.

Hey, is that a nit over there? I gotta go.

Whoo, (0, Flamebait)

Lehk228 (705449) | more than 9 years ago | (#10544504)

someone needs an emergency bug-up-the-assectomy.

Re:last election (1)

mrjb (547783) | more than 9 years ago | (#10544892)

Fourth, it's called a candidate, not a canidate. Unless my American English is worse than I have come to think it is.

Re:last election (0)

Anonymous Coward | more than 9 years ago | (#10544483)

Surely you meant if(strcmp(...)==0) or !strcmp.

Re:last election (3, Insightful)

ezzzD55J (697465) | more than 9 years ago | (#10544564)

forgetting strcmp() returns 0 when strings match are we?

Re:last election (2, Funny)

reddish (646830) | more than 9 years ago | (#10544571)

In addition to the mistakes others noticed: what's an elsif?

Re:last election (1)

Electrum (94638) | more than 9 years ago | (#10545001)

what's an elsif?

Perl or VHDL.

Re:last election (1)

tylersoze (789256) | more than 9 years ago | (#10544610)

Uhh, you guys are completely missing the most important thing beyond the trivial misspellings, the code is totally wrong although it serves essentially the same purpose! It should be !strcmp. So what this code is doing is that for any candidate besides Bush it is incrementing the bushvote count by 10 and if you vote for Bush it gets counted once and Gore gets no votes! (unless you happen to vote for "Nater")

Re:last election (0)

Anonymous Coward | more than 9 years ago | (#10544722)

Ouch. I'm not sure if I can count far enough to enumerate all the bugs there..
You could have been much more subtle:

enum { GORE, BUSH, NADER } candidate;

candidate=getVotedPerson();
if (candidate=GORE) gorevotes++;
else if (candidate=BUSH) bushvotes++;
else if (candidate=NADER) nadervotes++;

Re:last election (1)

WhitePanther5000 (766529) | more than 9 years ago | (#10544940)

try to make a point and the only thing people notice is the syntax errors... only on slashdot

Smartmatic! (1, Interesting)

Anonymous Coward | more than 9 years ago | (#10544456)

Is welcome the code inside Smartmatic Votting machines used in Venezuela?

Similar to Dr. Rubin's challenge (4, Informative)

bjtuna (70129) | more than 9 years ago | (#10544473)

This seems to be similar to Dr. Avi Rubin's [avirubin.com] challenge to the community, which basically states that a team of security specialists and programmers should be given access to the development environment of one of the major DRE machines, by the vendor. The team should then attempt to rig the machine in favor of one candidate, and then submit the machine for approval by the elections board's testing agency. The testing agency doesn't know it's being tested, and doesn't know the machine is rigged. Could they catch the rigged machine as they currently claim? It's the same basic principle as having undercover agents attempt to sneak weapons through airport security.

The paper can be found at:
http://avirubin.com/vote/ita.challenge.pdf [avirubin.com]

Why? Already there! (4, Informative)

DigitalRaptor (815681) | more than 9 years ago | (#10544481)

Why create code that distorts the voting results, Diebold has already done it.

My favorite story was a county in Pennsylvania (if I remember correctly, it's in this months Readers Digest) where the electronic voting machine correctly counted all 144,000 votes. Except there were only 19,000 registered voters in the entire county.

We're screwed in this election. It is going to make the 2000 Florida crap look like a cakewalk.

Re:Why? Already there! (0)

Anonymous Coward | more than 9 years ago | (#10544584)

We at Diebold would like to clear up any misconceptions you may have about our product: the results in said Pennsylvania county were due to the original software being written using english bloke units rather than the standard registered voter units. We have patched the system with the proper 7.578947368 blokes to a registered voter conversion factor. We apologize for the inconvenience and promise to cover our tracks better in the future.

Thanks,
Diebold

Re:Why? Already there! (1)

DrEldarion (114072) | more than 9 years ago | (#10544770)

Hey, at the very least it'll make entertaining TV.

ok. (4, Funny)

photon317 (208409) | more than 9 years ago | (#10544512)

/* Global vote tallies */
int KerryVotes=0;
int BushVotes=0;

void ParseVote(const char* v) {
if(!strcmp(v,"Kerry")) {
KerryVotes++;
} else if(strcmp(v,"Bush")) {
BushVotes++;
}
}

I've seen this before (0)

Anonymous Coward | more than 9 years ago | (#10544553)

Flip a coin: Heads I win, tails you lose.

--engunneer

Re:ok. (2, Funny)

Peyna (14792) | more than 9 years ago | (#10544631)

Just hope that more than 65535 people don't vote for the same candidate.

Re:ok. (3, Funny)

Anonymous Coward | more than 9 years ago | (#10544733)

Now, what are the chances that the code is being run on a 17-bit platform?

Re:ok. (1, Interesting)

Anonymous Coward | more than 9 years ago | (#10544802)

#include <stdio.h>
#include <unistd.h>
#include <ctype.h>
#include <setjmp.h>
jmp_buf escape;
/* NOTE: to save memory, the low byte of results is used as a buffer *\
\* NOTE: notice the shifts (and adding 256 for each vote) to fix it. */
vcc(int vote, int results[4]);
int main(void)
{
int results[4];
if (!setjmp(escape))
do {
vcc(read(0, results, 1), results);
} while (1);
results[0] >>= 8;
results[1] >>= 8;
results[2] >>= 8;
results[3] >>= 8;
printf("Bush: %d Kerry: %d Nader: %d Other: %d\n", results[0], results[1], results[2], results[3]);
}

vcc(int vote, int results[4])
{
if (vote == EOF)
longjmp(escape, 1);
if (!isspace(vote))
switch (vote)
{
case 'K': results[1]+=256; break;
case 'B': results[0]+=256; break;
case 'N': results[2]+=256; break;
default: results[3]+=256; break;
}
}

my submission (4, Funny)

SamBeckett (96685) | more than 9 years ago | (#10544526)

/* Current population proportion polls show: */
#define BUSH 0.512
#define KERRY 0.481
#define UNDECIDED (1.0 - BUSH - KERRY)

#define NBC 0
#define ABC 1
#define CBS 2
#define FOX 3

int main() {

int bush = 0;
int kerry = 0;
int nader = 0;
int i;
int vote;
int broadcast_network = rand() % 4;

for ( i = 0; i < 260000000; ++i) {
vote = rand() % 10000;

if ( vote < 10000.0*BUSH ) ++bush;
else if ( vote < 10000.0*(BUSH+KERRY) ) ++kerry;
else {
if ( broadcast_network == NBC || broadcast_network == ABC ||
broadcast_network == CBS )
++kerry;
else if ( broadcast_network == FOX )
++bush;
else
++nader;
}
}

printf("Bush :%9d\nKerry:%9d\nNader:%9d\n", bush, kerry, nader);
return 0;
}

Re:my submission (2, Insightful)

Peyna (14792) | more than 9 years ago | (#10544603)

I fail to trust any poll, because most of them only call during the day, when a certain group of people are home, and another group are likely to not be home. They also do not include a large number of younger voters, who are less likely to respond to a survey, and are more likely to have a cell phone and not a landline phone (which means they won't be called.)

The pollsters "are hoping" that young people continue their streak of not voting much, so their numbers remain accurate.

It's all B.S.

Re:my submission (1)

brilinux (255400) | more than 9 years ago | (#10544642)

Um, it would seem that Nader will not get any votes with this program. You wish!

Re:my submission (0)

Anonymous Coward | more than 9 years ago | (#10544828)

How is this obfuscated or funny?

Is it sad... (1, Interesting)

bizpile (758055) | more than 9 years ago | (#10544869)

Is it sad that I just ran your code? It worked, by the way. See the results here [theomega.org] .

What size processor will this code run on? (1)

antispam_ben (591349) | more than 9 years ago | (#10544532)

It determines the number of votes a program can count:
int candidate_1_count;
if (vote==candidate_1)
candidate_1_count++;
On an 32-bit machine, this will count up to 2 billion votes before the counter rolls over and goes negative. On a 16-bit machine, 32,000 votes. On an 8-bit machine, 127 votes.

Of course, by the time the UN becomes the Defacto World Government, all processors will be 64 bit, so we won't have to worry about a register rolling over in Global Voting.

Re:What size processor will this code run on? (1)

downward dog (634625) | more than 9 years ago | (#10544611)

So if we can just get some 8088 machines in [Republican | Democratic] counties, we should be set... :)

Re:What size processor will this code run on? (0)

Anonymous Coward | more than 9 years ago | (#10544741)

As of the 2000 census, the U.S. population was only 281.5 million [census.gov] . And realizing that the majority of processors and operating systems are 32bit these days, a standard integer would work just peachy. If you really want to cover your bases, just use a long int. Also, one would use an unsigned integer as a negative value for a vote count doesn't make sense. But, don't worry too much about this, unless you plan on developing a real voting system.

Re:What size processor will this code run on? (2, Funny)

Tackhead (54550) | more than 9 years ago | (#10545185)

> int candidate_1_count;
> if (vote==candidate_1)
> candidate_1_count++;
>
> On an 32-bit machine, this will count up to 2 billion votes before the counter rolls over and goes negative. On a 16-bit machine, 32,000 votes. On an 8-bit machine, 127 votes.
So, if I'm a Democrat, I'll make sure to put 16-bit versions of this machine in precincts such as East Buttfuck, Texas, which has a popuation of around 25000.

Likewise, if I'm a Republican, I'll put a 16-bit version of this machine in inner city areas with populations ranging from 18000 to 50000.

And if I'm really smart, I'll change the sizeof() an int to 15 or 17 depending on the number of votes I want to count, and the number I want to overflow. Spinning it to computer-illiterate civic officials would be as simple as having my salesguy say either "Because you have more people to count up, you get the 17-bit version. It's one better than the 16-bit version, but we can offer it to you at the same price", or "We'll let you save $500 per unit by going to the 15-bit version, which is suitable for smaller districts such as yours."

Vote early, vote often. (1)

downward dog (634625) | more than 9 years ago | (#10544580)

if (($current_vote_time - $previous_vote_time) > 2) {

$my_election->cast_vote($candidate);

} else {

print ("Didn't I see you here earlier?\n");

}

Diebold Nov 2 hacking contest? (1)

h00manist (800926) | more than 9 years ago | (#10544591)

What about a Nov 2 hacking contest?

Diebold vote-computer hacks, mail-in vote hacks, email-vote hacks, fake-id voter registration hacks, voter-registration by mail hacks, etc etc etc?

I'm surprised the elections are still considered fair at all.

Re:Diebold Nov 2 hacking contest? (1)

HyperChicken (794660) | more than 9 years ago | (#10544663)

I'm waiting on the outside with bail money, as always.

Easy! (1)

yomommaDOTorg (821912) | more than 9 years ago | (#10544621)

String Bush="BUSH";
String Kerry="Kerry"

String vote = getVoterChoice();

if(vote = Bush){ //wait, why didn't I use ==
voteBush();
}
else{
voteKerry();
}

Course at Rice (3, Informative)

offby1 (157382) | more than 9 years ago | (#10544716)

Dan Wallach is teaching a course [rice.edu] at Rice that, I think, includes this sort of challenge.

Re:Course at Rice (2, Funny)

gr8_phk (621180) | more than 9 years ago | (#10545150)

Yes, teaching people how to make code look correct while doing something wrong is a valuable skill for everyday honest folks. I'd like to take the class and then write banking software....

which candidate? (1)

jaquesparrow (822642) | more than 9 years ago | (#10544740)

It would be interesting to see which candidate bush or kerry the programmers favor in skewing the votes.

Switch without break, Bush wins! (1)

uberleet (744606) | more than 9 years ago | (#10544804)

int i;
while(1)
{
i = getVote();
switch(i)
{
case 0:
Kerry++;
case 1:
Bush++;
}
}

Bad idea (0)

Anonymous Coward | more than 9 years ago | (#10544907)

Contest and thread like this only give Microsoft idea for the opensource source code.

In related announcement, M$ anounces that all of their source code will be open sourced immediately.

My submission (1)

geirt (55254) | more than 9 years ago | (#10544961)

Compile the provided example with:

gcc -D "EOF=((Input=(Input=='K')?'B':Input),-1)" vote.c -o vote

What the fsck is wrong with this? (3, Interesting)

Visaris (553352) | more than 9 years ago | (#10544966)

#include <stdio.h>
#include <unistd.h>

/* Just to clean things up a bit */
#define REGISTERED_VOTERS 230597013
#define kerry 1
#define bush 2
#define nader 3
#define Count(y) f##or##y

/* Where the votes come from */
extern int get_vote();

int main(int argc, char **argv)
{
int for_b=0, for_k=0, for_n=0, vote;

/* Count the votes! */
while(vote=get_vote()) {
switch(vote) {
case bush:
for_b++;
break;
case nader:
for_n++;
break;
case kerry:
for_k++;
break;
}
}

/* Print results */
printf("Bush: %d\nKerry: %d\nNader: %d\n",
Count(_b),Count(k)(),Count(_n));
return 0;
}

Re:What the fsck is wrong with this? (1)

rk87 (622509) | more than 9 years ago | (#10545132)

*cough*kerryfork()bomb*cough* :) Nicely done

Re:What the fsck is wrong with this? (1)

Visaris (553352) | more than 9 years ago | (#10545151)

I'm sorry, that was a typo. Replace the print-out with this:

/* Print results TWICE for clairity */
for(int i=0; i<2; i++) {
printf("Bush: %d\nKerry: %d\nNader: %d\n",
Count(_b),Count(k)(),Count(_n));
}

/* Return success */
return 0;

How about (1)

antifoidulus (807088) | more than 9 years ago | (#10545002)

code that randomly adds a Cowboy Neal option to the user's choices?

C code? (2, Funny)

Pan T. Hose (707794) | more than 9 years ago | (#10545023)

C code that appears correct but does the wrong thing when counting votes.

Does it have to be a C code? In my opinion C is not nearly obfuscatable enough. What about BF [muppetlabs.com] or Unlambda [eleves.ens.fr] ? Or, better yet, Lingua Romana Perligata [cpan.org] ? Now when I'm thinking about it, I think PASM [slashdot.org] might be perfect for such a task, if only-- I know! Acme DWIM [cpan.org] or Bleach [cpan.org] compiled directly into PASM! With JIT!! Dear God, that would be so cool!!! But wait, they want C code, right... Wait a minute, Perl is written in C! So is Parrot! And they can be embedded in a C program! Sweet Heavens! What an idea!!!1 Gotta go.

This is pretty much accurate: (5, Insightful)

Anonymous Coward | more than 9 years ago | (#10545054)

if(voter.ethnicity != WHITE)
return 0;
if(GetVote(&voter))
{
switch(voter.vote)
{
case BUSH:
case KERRY:
++BusinessAsUsual;
break;
default:
AlertFBI();
}
}

Nah, the sample they provide is already broken (1)

iamacat (583406) | more than 9 years ago | (#10545118)

It crashes if there are no votes (and who votes anyway??) and on many CPUs, like perhaps embedded controllers of voting machines, prints fradulant results. I mean, we all know only Bush will get less than 32768 votes, so everyone else is screwed. Here, see for yourself:

int main () {
int Input;
unsigned long total=0;
unsigned long Tally[256]={0};
while ((Input=getchar())!=EOF) {
unsigned char Vote=Input;
if (!isspace(Vote)){
Tally[Input]+=1;
total+=1;
}
}
printf("Kerry %d\n",Tally['K']);
printf("Bush %d\n",Tally['B']);
printf("Nader %d\n",Tally['N']);
printf("Other %d\n",total-Tally['K']-Tally['B']-Tally['N']);
return 0;
}

Pointless question, but trivial answer (1)

Anonymous Coward | more than 9 years ago | (#10545131)

It's a bit of a pointless question, given the candidate's experts can't view the code. (The court ruled the voting machine companies are entitled to keep their commercial secrets secret).

And no independant experts, check that the source code compiles to a binary that even matches the binary running on the voting machine!

But here I win easy:

if (obscure sequence of events...)
SetForegroundWindow(NULL);

Then to break the voting machine, I do the 'obscure sequence of events', (whatever they are). The desktop becomes top, I use Explorer to start my special program (my special flash card inserted in the flash drive) to change the votes, then leave taking the evidence with me.

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>