addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupsimageimagesinstagramlinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1outlookpersonStartprice-ribbonImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruseryahoo

Re: [jsmn] Challenge: Write Ranked-Choice-Voting in JavaScript

From: Erik O.
Sent on: Friday, November 8, 2013 9:23 AM

It might be worth looking up the statute for the actual algorithm. For example, if the bottom three candidates have X, Y, and Z votes, and Y + Z  < X, then both Y and Z can be eliminated in one round. (That's not the full detail of the rule, just a case I know offhand because it happened twice in the mayoral count.)

On Nov 8,[masked]:16 AM, "Bill Bushey" <[address removed]> wrote:
Hi JavaScriptMN,

It's been three days since the election, and still we do not have a certified winner for the mayoral election in Minneapolis. This delay, plus the computational nature of Ranked-Choice-Voting (RCV), has sparked a discussion among some of us over at Open Twin Cities about how RCV can be implemented as a simple computer program, what some advantages would be, and thoughts on why it hasn't yet. It's also led to two implementations of the RCV algorithm, one in Java and one in R.

Seeing folks create Java and R versions of RCV got me to wonder just how many implementations of RCV could be created by, say, the end of the weekend. Its a fun little project for anybody who's new to JavaScript, or looking for a project to spend an hour or so on. Minneapolis has a page up with information on the process itself, and from what I know of it, the algorithm boils down to:

  1. Create a data structure that represents a ballot with a 1st, 2nd, and 3rd choice for office
  2. Count up the number of 1st choice votes for each candidate. If a candidate has 50% + 1 votes, declare that candidate the winner.
  3. Else, select the candidate with the lowest number of 1st choice votes, pop the 1st choice off of any ballot for which that candidate was the first choice, and remove that candidate from all other ballots.
  4. Goto 2

So, here is a fun challenge from Open Twin Cities: be the first person to implement RCV in JavaScript. The person who replies to this thread first with a link to a Github repo with a working RCV implementation will get a shout-out on Twitter from Open Twin Cities, and a mention on OTC's site in a forthcoming post.

Cheers, and have fun,
Bill Bushey
Open Twin Cities

Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Bill Bushey ([address removed]) from JavaScriptMN.
To learn more about Bill Bushey, visit his/her member profile
To report abuse or block this person, please click here
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]

Our Sponsors

  • Twilio

    Pizza sponsor and a Super simple API for SMS, MMS, Voice/VoIP

  • Olson

    The great people at Olson are providing us the space for our meetings.

  • TrackJS

    Food Sponsor and awesome error reporting

  • ReachLocal

    Video Streaming Sponsor

  • Empulse

    Video Streaming Sponsor

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy