6 kyu

Find a Bunch of Common Elements of Two Lists in a Certain Range

490 of 891raulbc777
Description
Loading description...
Fundamentals
Data Structures
Algorithms
Mathematics
Logic
Strings
  • Please sign in or sign up to leave a comment.
  • trashy_incel Avatar

    Java:

    • sample tests do not compile (missing List import)
    • the criterion for odd numbers incorrectly classifies negative odd numbers as even numbers
  • daedsky Avatar

    I optimised from passing 30 test cases to 200 test cases in python and am now running out of ideas for optimization. Is it supposed to be more optimised or is the random test case is in infinite loop causing timeout?

  • alxappi Avatar

    In java version I've not passed tests for odd numbers less than zero. For example -3 occured twice or more in arrA and arrB, but this number are not expected in final list. I've wrote "quickfix" for filtering odd numbers less than zero and pass all test. In reference solution I've found line like this "i % 2 == 1 : 0 (by odd or even)". But for numbers less than zero we take -1 for odd numbers hence negative numbers are filtered in reference solution. Maybe I've not understand this task, please check my points.

  • JorisDeRoeck Avatar

    Very Important: For javascript run the tests only in Node v6.6.0 and Node v6.6.0/Babel

    This Node version is not available in the dropdown

  • Unnamed Avatar

    Ruby: the solution is executed while the tests are loaded. For example, 1 / 0 results in a test loading error instead of a normal error message:

    An error occurred while loading ./spec/solution_spec.rb.
    Failure/Error: 1 / 0
    
  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • ejini战神 Avatar
    • Ruby 3.0 should be enabled

    • Parameter name should be snake_case

  • ejini战神 Avatar
    • Python new test framework should be used

    • Parameter name should be snake_case

  • ejini战神 Avatar
    • Description should be language-agnostic

    • Very Important: For javascript run the tests only in Node v6.6.0 and Node v6.6.0/Babel. should be removed

  • farhanaditya Avatar

    JS: Node v14 should be used along with its appropiate assertion tools (Mocha + Chai). Refer to this and this

  • Blind4Basics Avatar

    kata broken (python) by the new runner. Need access to the edit panel and corrections

  • swarrius Avatar

    Just reflecting in hindsight... I had to write several functionally correct versions looking for an optimized one to deal properly with huge arrays (random tests). I was thinking that struggling with optimization this deep might be too much for level 6, in python at least.

  • shahriar_siddik Avatar

    Fun kata to solve. Thanks raul.

  • Blind4Basics Avatar

    Nice one, but the tests are maybe a little bit too much greedy, at this time : there are several validated codes that do not work anymore, just now (too much people on codewars server, I think. At least for python). But I learned some stuff, here ! ;)

  • nubprogramer Avatar

    This comment has been hidden.

  • Insti Avatar

    they occur twice or more in A and B

    This is ambiguous and needs to be clarified (and tested for in the basic tests)

    "They occur more than once in A and more than once in B"

  • smile67 Avatar

    Hi Raul, as always good kata, for me Ruby and JS works fine;-)... Have a nice day!

  • Insti Avatar

    I have a solution (Ruby) that passes the basic tests, but fails the Random Tests. Whatever the problem is there should be enough basic tests that it is detected at that stage.

    Random tests give no indication of what the failure was.

    Also the random tests take too long to run, is it really necessary to test multiple huge arrays? What is this testing for?

  • Insti Avatar

    they are present in both ones

    Does this mean "both arrays"?

  • Insti Avatar

    I'd like to see simpler example test cases that demonstrated each of the rules.

  • Insti Avatar

    Please use full words in the description.

    arrA = [1, -2, 7, 2, 1, 3, 7, 1, 0, 2, 3]
    arrB = [2, -1, 1, 1, 1, 1, 2, 3, 3, 7, 7, 0]
    rng = [-4, 4] # is the range of the integers from -4 to 4 (inclusive)
    wanted = 'odd'
    

    Why not:

    array_A = [1, -2, 7, 2, 1, 3, 7, 1, 0, 2, 3]
    array_B = [2, -1, 1, 1, 1, 1, 2, 3, 3, 7, 7, 0]
    range   = [-4, 4] # is the range of the integers from -4 to 4 (inclusive)
    wanted  = 'odd'
    
  • user8476848 Avatar

    Fun Raul! thanks!