Ad
  • Custom User Avatar

    ok figured it out. The description could have been a bit less terse...
    The important line is "The votes are tallied from the each voter's first choice."
    I was throwing away each round's votes (i.e. shifting from the array). After elimination, you always should count the first preferences again.

  • Custom User Avatar

    I'm missing something... I've got the bit about eliminating canidates with 0 votes (i.e. collect all candidates before beginning the count). But what about this:
    [ [ 'b', 'a', 'e', 'd', 'c' ],
    [ 'a', 'd', 'e', 'c', 'b' ],
    [ 'c', 'a', 'd', 'b', 'e' ],
    [ 'c', 'a', 'e', 'b', 'd' ],
    [ 'd', 'c', 'e', 'a', 'b' ] ]
    Expected: c, instead got: a
    Round 1 a: 1, b: 1, c: 2, d: 1, e: 0
    e eliminated
    Round 2 a: 4, b: 1, c: 3, d: 2
    a wins?

  • Custom User Avatar

    Great fun! I think it was a deserved 2 kyu. It was hard-ish to debug. I was on a wrong track: I had the basic function in half an hour but I was combining the individual values to a single rgb value and then applying the weights, which worked for all but the last case which was pretty mangled. Not sure why this doesn't work. I thought it had something to do with normalisation and I think the question could have been clearer in this regard.

  • Custom User Avatar

    Loved it: spent a couple of commutes thinking about how to solve it. Thought I had a unique solution until I saw most did it like I did :)

  • Custom User Avatar

    Easy money :)