Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • I have the same issue, when I copy it into IDLE and run it with the same input as the test it comes back 'ind' but it's getting None in the test. (It's getting None for both tests but None is correct for the other one.)

  • JavaScript

    I got this error (only) on random tests

    Expected: undefined, instead got: 'undefined'

    I tried

    return undefined; and return;

  • Changed it back (now the tests expect undefined not as a string anymore). Why GiacomoSorbi always resorts to the worst resolution of things? :thinking:

  • Fixed (now it expects undefined not as a string anymore)

  • Thanks! Helped alot

  • It wants it returned as a string. so it should be 'undefined' instead of undefined


  • Everything works, except for the undefined ones. I get this error message:

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

    Can somebody tell me whats wrong?

  • The following list:

    [['Johan Liebert', 'Frank Underwood', 'Abelt Dessler', 'Reinhard von Musel', 'Lex Luthor', 'Daisuke Aramaki'],
    ['Reinhard von Musel', 'Daisuke Aramaki', 'Lex Luthor', 'Frank Underwood', 'Abelt Dessler', 'Johan Liebert'],
    ['Daisuke Aramaki', 'Frank Underwood', 'Abelt Dessler', 'Lex Luthor', 'Johan Liebert', 'Reinhard von Musel'],
    ['Frank Underwood', 'Johan Liebert', 'Lex Luthor', 'Reinhard von Musel', 'Abelt Dessler', 'Daisuke Aramaki'],
    ['Daisuke Aramaki', 'Abelt Dessler', 'Lex Luthor', 'Reinhard von Musel', 'Johan Liebert', 'Frank Underwood'],
    ['Abelt Dessler', 'Lex Luthor', 'Reinhard von Musel', 'Daisuke Aramaki', 'Johan Liebert', 'Frank Underwood']]

    should give None as the answer, as after counting for the first time, 4 candidates get 1 vote each (least value) and after removing all of them, 2 candidates are left, and in the second round of counting, they both get equal votes (3 each). It says the result should be 'Daisuke Aramaki', not None.

  • Each length is calculated twice, so I can't even tell without testing if caching would help or not. And the complexity is just O(n * log n), the group lengths are not independent of the list length, they are made of the same items.

  • It has approximate time complexity O(n log n). ( I already thought so. But I checked. ) Your C or assembly solution might have time complexity O(n), but will very, very probably also have O(n log n).

    No, length is not cached. But even without, time complexity is something like (O m n log n) with m the length of the longest group. That's approximately a small constant except in extreme cases. Caching length would be a good thing here.

  • erm, did this refactoring in preparation for the "evil" version, and forgot to remove the "thickened" part when submitting this one >.<

  • Augh, sorry I procrastinated so long on looking at this---I haven't been on Codewars much lately. Fixing it now.

  • Loading more items...