7 kyu

Difference between biggest 2 numbers

1,492 of 1,861kyduke
Description
Loading description...
Arrays
Algorithms
  • Please sign in or sign up to leave a comment.
  • hobovsky Avatar

    This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/176.
    Please join the discussion to help us identify duplicate kata and retire them.

  • laurelis24 Avatar

    Those duplicates made this much harder. xD

  • akar-0 Avatar

    JavaScript tests (both basic and attempt) crash:

    Test Results:
    
    "it" calls must be invoked within a parent "describe" context
    
    STDERR
    /runner/frameworks/javascript/cw-2.js:237
              throw ex;
              ^
    "it" calls must be invoked within a parent "describe" context
    
  • stanislv Avatar

    There seems to be an issue with JS version. Sample and all random tests are fine, but fixed test shows an error "expected 100 to equal 0". Can't wrap my head around how it is possible. Can anyone help?

  • Dramex Avatar

    why array.sort() not working

  • 1nexion Avatar

    This comment has been hidden.

  • Coderator Avatar

    Hey, I made a Python translation of this kata, can you please check that?

  • MyNameWahyudi Avatar

    Why my 3 solution always failed i try in codewars, but i have try it in my Viscode and my answer i get is always correct. i have followed the specified instructions by not using the sort method. Please help me sir!!

  • JohanWiltink Avatar

    The original JS version ( ie, the reference and example solution. same goes for the CS version ) depends on array elements being non-negative. This has been added to the description, and JS, CS and Ruby testing has been updated.

    C testing has not been updated. Somebody please do that. TIA.

    JS and CS versions have also been updated to guarantee inputs of at least two elements ( they didn't ), and JS version has been updated to chai and current node.

  • yar83 Avatar

    My C version passes all various and sample tests except last one with INT_MAX + 1ll. Please, point me out to information I need to know to solve this problem. For JS I've managed for 1 minute, and it's a bit frustrating to immediately get stuck in another language. ))

  • trashy_incel Avatar

    This comment has been hidden.

  • user9644768 Avatar

    Ruby 3.0 should be enabled.

  • user6922963 Avatar

    This comment has been hidden.

  • cmdicely Avatar

    Some of the random test cases do not comport with the problem description; the problem description specifies an array of natural numbers, but the random test cases include negative integers. As the natural numbers are the non-negative integers, this is an inconsistency.

  • GiacomoSorbi Avatar

    Kata greenlit; kudos kyduke :)

  • g964 Avatar

    I think there are problems with the random tests (Ruby). Below an example of the 42 failed random tests: arr = [-842, -166, 61, -291, 726, 736, -49, -35, 386, 96] The difference between the two biggest is 736 -726 = 10 but the test expects 340. Same thing with:

    Testing for [-70, 459, -100, -407, 7] It should work for random inputs too - Expected: 77, instead got: 452

    The 2 biggest are 459 and 7 hence a difference of 452 but not of 77, unless I don't understand the description...

    PS1: the fixed tests are correct. PS2: it would be good to have some "Run Tests".

  • matt c Avatar

    Random test cases would be great! If you need help with them I'm here for you :)

  • GiacomoSorbi Avatar

    Ruby translation submitted, if you want to approve it :)

    I could also translate it into Python, but while I can certainly disable the sorted() function, I know of no way to disable builtin methods like .sort(): we could just write in the text not to be lame and use short-cuts and that should do as this is a beginner kata (so even if one "cheats", he ultimately gets to read good solutions), but I leave the last word to you.