Ad
  • Custom User Avatar
  • Default User Avatar
  • Default User Avatar
    [   ['Abelt Dessler', 'Reinhard von Musel', 'Lex Luthor', 'Drake Luft', 'Brian J. Mason', 'Frank Underwood'],
        ['Drake Luft', 'Lex Luthor', 'Frank Underwood', 'Brian J. Mason', 'Reinhard von Musel', 'Abelt Dessler'],
        ['Drake Luft', 'Reinhard von Musel', 'Lex Luthor', 'Frank Underwood', 'Brian J. Mason', 'Abelt Dessler'],
        ['Lex Luthor', 'Drake Luft', 'Frank Underwood', 'Brian J. Mason', 'Reinhard von Musel', 'Abelt Dessler'],
        ['Reinhard von Musel', 'Abelt Dessler', 'Drake Luft', 'Lex Luthor', 'Frank Underwood', 'Brian J. Mason'],
        ['Lex Luthor', 'Brian J. Mason', 'Frank Underwood', 'Abelt Dessler', 'Drake Luft', 'Reinhard von Musel']  ]

    It should work for random inputs too - Expected: undefined, instead got: 'Lex Luthor'

    in the first round 2:2 between Lex and Drake, then 1:1 between them in the second, and in the third 2:1 in favor of Lex, why should there be a draw? Most likely I didn't understand the condition. help please.

  • Custom User Avatar

    Tip for those who are stuck in the random questions: don't mutate the array of votes. (should be mentioned in the description)

  • Custom User Avatar
  • Custom User Avatar

    No example tests

  • Default User Avatar

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

  • Custom User Avatar

    Needs random tests

  • Custom User Avatar

    Needs sample tests

  • Default User Avatar

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

  • Default User Avatar

    Not mentioned in the description: in order to pass the test cases, you must also exclude from the runoff any candidate who received no votes.

  • Default User Avatar

    I'm liking this kata, but I'm running into one final problem when trying to complete it. While the description doesn't mention it, I went ahead an included checks for duplicate flags and names in the boolean flags, argument flags, and arguments. My thought, along with avoiding duplicate names in the output (which isn't too big of a deal if the associated flags are unique), was that we should avoid the situation where the input is something like "-b" and "b" is defined as both a boolean and an argument flag. In the first set of test cases, however, this situation does arise.

    How should duplicate flags or names be handled?

  • Custom User Avatar

    Descriptions are very unclear and sometimes completely wrong. Even the wikipedia page does not help as there are many variations.
    The only way to figure out the specific rules is adding a puts at the top of the method and working towards the expected result.

    Should provide more samples cases or change the description.

    Do not use "Start over." in the description. You do not start over, you keep a running tally.

    Try numbering the steps so you can refer to them.
    It would be good to mention how the votes are tallied after removing the bottom candidates. Maybe something like...
    "After removing the bottom candidates, count all the top votes for the "new" voters list and add those votes to the previous tally. Go to step 3"
    (If the first-place candidate has more than half the total votes, they win.)

    "first-place" could be misunderstood, maybe reword that to...
    "If a candidate has more than half the total votes, they win."

  • Default User Avatar

    I've a couple test cases that demonstrates how this problem is insufficiently defined and needs more test cases:

    voters1 = [ [:a, :b, :c], [:a, :b, :c], [:a, :b, :c], [:b, :c, :a], [:b, :c, :a], [:c, :b, :a], [:d, :b, :a], ]
    voters2 = [ [:a, :b, :c], [:a, :b, :c], [:a, :b, :c], [:b, :c, :a], [:b, :c, :a], [:c, :b, :a], [:d, :b, :a], [:e, :b, :a], ]
    

    For example, @hencethus and @evilscott/@Dima83 have differing solutions that pass the tests. However:

    @hencethus's solution maintains tallies across iterations, disqualifying losers along the way.

    • voters1 - no winners because :a and :b tie during the second iteration
    • voters2 - declares :b as winner during the second iteration

    @evilscott's and @Dima83's solution declares the candidate with the most first-votes to be the winner rather than the one with "more than half the total votes"

    • voters1 - finds the winner to be :a during the first iteration
    • voters2 - finds the winner to be :a during the first iteration