addressalign-toparrow-leftarrow-leftarrow-right-10x10arrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1languagelaunch-new-window--smalllight-bulblightning-boltlinklocation-pinlockm-swarmSearchmailmediummessagesminusmobilemoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstar-shapestartickettrashtriangle-downtriangle-uptwitteruserwarningyahooyoutube

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

From: Tyler A.
Sent on: Friday, November 8, 2013, 1:08 PM
Of course, I blame you for forcing me to code over the lunch hour.  ;)


I don't think I would use the code to judge the election itself if I was doing this in an official capacity, but it would be good to double-check the election results.


--
Tyler Akins


On Fri, Nov 8, 2013 at 9: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]

People in this
group are also in: