Slashdot Mirror


Obfuscated Vote Counting Contest

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."

26 of 223 comments (clear)

  1. I WIN! by AmigaAvenger · · Score: 5, Funny

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

    1. Re:I WIN! by qube99 · · Score: 2, Funny

      10 print "KERRY WINS!" 20 goto 10

    2. Re:I WIN! by anonymous+cowherd+(m · · Score: 4, Funny

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

      --
      http://neokosmos.blogsome.com
    3. Re:I WIN! by Anonymous Coward · · Score: 1, Funny

      #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;
      }

    4. Re:I WIN! by Phillup · · Score: 4, Funny
      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.
      --

      --Phillip

      Can you say BIRTH TAX
    5. Re:I WIN! by crywolf · · Score: 2, Funny

      And in election news, a record 117% of the nation's registered voters went out and voted.

      --
      CAUTION: Product may be hot after heating
    6. Re:I WIN! by smittyoneeach · · Score: 2, Funny

      In other words failure to use a break; statement in a C switch construct has a qualitatively similar effect to the act of writing a rather longish sentence while omitting punctuation of any sort upon a human reader.

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    7. Re:I WIN! by JUSTONEMORELATTE · · Score: 4, Funny

      You're missing something more important than a default case.
      Aww c'mon, give the guy a break already!

      --
      free gmail invites -- only one left!

  2. Damn by antifoidulus · · Score: 4, Funny

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

  3. Gah by Xpilot · · Score: 1, Funny

    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!

    --
    "Backups are for wimps. Real men upload their data to an FTP site and have everyone else mirror it." -- Linus Torvalds
  4. Patent pending by GrAfFiT · · Score: 5, Funny

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

  5. Re:last election by Sv-Manowar · · Score: 0, Funny

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

  6. Re:Summary of this year's election by tomhudson · · Score: 4, Funny
    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;
    }
  7. ok. by photon317 · · Score: 4, Funny

    /* 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++;
    }
    }

    --
    11*43+456^2
    1. Re:ok. by Peyna · · Score: 2, Funny

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

      --
      What?
    2. Re:ok. by Anonymous Coward · · Score: 3, Funny

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

  8. my submission by SamBeckett · · Score: 4, Funny
    /* 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;
    }
  9. Re:last election by Anonymous Coward · · Score: 5, Funny

    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.

  10. Re:last election by reddish · · Score: 2, Funny

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

  11. Re:Nader not Nater by OneDeeTenTee · · Score: 3, Funny

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

    And they both have the same chances of becoming president.

    --
    Stop the world; I need to get off.
  12. Re:And while you're hacking away... by Tackhead · · Score: 2, Funny
    > ...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!

  13. C code? by Pan+T.+Hose · · Score: 2, Funny

    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 or Unlambda? Or, better yet, Lingua Romana Perligata? Now when I'm thinking about it, I think PASM might be perfect for such a task, if only-- I know! Acme DWIM or Bleach 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.

    --
    Sincerely,
    Pan Tarhei Hosé, PhD.
    "Homo sum et cogito ergo odi profanum vulgus et libido."
  14. Re:Course at Rice by gr8_phk · · Score: 2, Funny

    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....

  15. Re:What size processor will this code run on? by Tackhead · · Score: 2, Funny
    > 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."

  16. C is for wimps by Anonymous Coward · · Score: 1, Funny

    Real obfuscation is best expressed in Intercal. If we had voting software written in Intercal, we wouldn't even need to bother having the election.

  17. Leaked Diebold Code by NuclearDog · · Score: 2, Funny
    int KerryVotes = 0; /* ID = 0 */
    int BushVotes = 0; /* ID = 1 */

    function votefor(int id)
    {
    switch (votefor)
    {
    case 0: /* Vote for Kerry */
    KerryVotes++;
    case 1: /* Vote for Bush */
    BushVotes++;
    }
    }
    --
    This statement is forty-five characters long.