7 kyu

String matchup

1,863 of 5,046KenKamau
Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • big_M Avatar

    Hi, check kata [Translation] [Dart] [0]

  • XoRMiAS Avatar

    JavaScript should be updated to Node 18 and use chai.
    Updated in this fork

  • natan Avatar

    Issues on lua tests being flipped get closed and ignored. I guess I'll just raise it again? I'm confused, and fail to see why this would be difficult.

  • saudiGuy Avatar
  • imjasonmiller Avatar

    I've forked the Rust translation in order to update it to Rust 1.49 and updated rand::Rng::gen_range to its new signature that takes a std::ops::Range.

  • natan Avatar

    Lua: Test output is flipped. (Also the phrasing "passed in" is very unfortunate because that suggests it being input as opposed to actual... But I suppose that's the test framework's wording.) Showing the input would be nice too (input, actual, expected)

    reproducing/example

    (default/initial code)

    matchup = {}
    function matchup.solve(a,b)
     --code here
    end
    return matchup
    

    test/error output:

    Expected objects to be the same.
    Passed in:
    (table) {
      [1] = 2
      [2] = 1
      [3] = 0 }
    Expected:
    (nil)
    
  • bananaback Avatar

    Expected objects to be the same. Passed in: (table) { [1] = 2 [2] = 1 *[3] = 0 } Expected: (table) { [1] = 2 [2] = 1 } I found that the result of the problem is different from the result in the test case. Is this because I made a mistake? :v

  • IntuCode Avatar

    nice and easy

  • sanoy97 Avatar

    Lua Tests seem to be flipped as well, and some solutions dont make sense to me a = {tymrvliayc, gnoynzzlffuza, xyqenuyvkkcnhlc, fjyuhmthyz, ysgpduhplhdxipe} b = {gnoynzzlffuza, gnoynzzlffuza, ysgpduhplhdxipe} my solution {1, 1, 1} test passed in {0, 0, 0} expected {1, 1, 1}

  • vpoonai Avatar

    Something's up with the python version of this. My code keeps returning jumbled up/random counts of list elements (i.e. [0, 1, 2] should equal [2, 0, 1]).

    I tested the exact same code on trinket.io using test cases from here and I get the expected correct results. Not sure what's going on?

  • jami0821 Avatar

    Are the test cases correct? My solution is outputting the correct value based on the information in the testing case but still flagging it as incorrect.

    For example:

    arg a -> [ 'abcdefgh','fghi','abc','fghijk','fghij','fghi','fghij','abcd','efghij','cdefghij' ]
    arg b -> [ 'abc', 'abc', 'fghij', 'fghijk', 'abc' ]
    My result -> [ 1, 2, 1 ]
    

    Test case returns:

    It should work for random inputs too - Expected: [1, 2, 1], instead got: [1, 1, 2, 1, 1]
    
  • Souzooka Avatar

    This comment has been hidden.

  • TimmyCodewars Avatar

    It looks like an 'm' is missing on the first line of the Lua solution setup.

  • cesarc770 Avatar

    can this be solved with javascipt? It passed the tests except for the random numbers, but randit and randrange are python functions right? how would you do that with javascript? My solution is along the lines of comparing each item and adding the count to another array

  • Voile Avatar

    Approved

  • anter69 Avatar

    Cleaned up the description a bit.

    Also fixed the test cases: you should always use Test.assert_equals(user_solution, expected_solution), not the other way round.

    I also rewrote the random test suite to make it clearer, leaving yours as a comment. Feel free to use it or scrap it :-) Some words of advice:

    • randint() is a "simpler version" of randrange()
    • using human readable variable names helps you in the long run
    • instead of a = func() (returning a 2-item list) then using a[0] and a[1], you can use a1, a2 = func()

    Oh, and you may raise the difficulty of the tests (more and longer strings, more repeats, etc) without any problem.

    Cheers