Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Do they run secret test cases? For example, fib(1000000)?? My code is mathematically correct, and seems like it should be plenty fast enough, but when I insert
    return fib(500000) if n == 0
    at the top of the function, it times out.

    If this is the case, I guess I need to optimize for speed, but it sure seems like my code should be fast enough. There should be no stack issues, either, as I'm iterating, not recursing. Perhaps is it the shear size of the result that is a problem?

  • Custom User Avatar

    This is really interesting, because I started a statewide group in California, called Californians for Electoral Reform, about 20 years ago that promotes IRV and Proportional Representation. I also wrote software ("ChoicePlus Pro") used by the City of Cambridge to count their ranked ballots. IRV is being used in Minnesota, California, Massachusetts, and some other states last I heard. The best national source for more information is FairVote.org.

    The Description given is sufficient, although minimal, except perhaps for the last two bullet points. What happens is that each round you eliminate one or more candidates (the ones with the lowest vote total), distributing their votes to whoever is next on their ballots. So if my ballot is A, B, C, and A is eliminated, then my vote now goes to B. If B is eliminated, my vote goes to C. If everyone is eliminated, the vote is exhausted. After distributig votes, you check to see if the winner has a majority of the remaining votes. If you get down to two voters, the winner is the one with the most votes.

    And yes, you only look at the 1st place votes initially, though subsequent rankings are used when candidates start getting eliminated.