Ad
  • Custom User Avatar

    Yes, not easy to understand fully but maybe it is for that reason that the moderators gave a 4 kyu...
    Be sure that there are no errors in the tests.
    1:uuu and 2:sss have same length, s comes before u but 1 comes before 2.

  • Default User Avatar

    I'm a little bit confused about the sorting. I understood the order of length and then alphabetically (correct me if I misunderstood)
    The test:

    mix("looping is fun but dangerous", "less dangerous than coding"); // => "1:ooo/1:uuu/2:sss/=:nnn/1:ii/2:aa/2:dd/2:ee/=:gg"

    Shouldn't be the "s" before the "u", despite being the "u" in s1? The same for "1:ii" and "2:aa"?

    EDITED: It seems, as a user says down in the chats, that the order is 1) Qty 2) String number 3) Alphabet

  • Default User Avatar

    Ye, could be the reason, I replaced it with a small func anyways.

  • Custom User Avatar

    This method (repeat) has been added to the ECMAScript 6 specification and may not be available in all JavaScript implementations yet.

    Maybe it is for that reason?

  • Default User Avatar

    Hi, I{m having a problem while running tests: "TypeError: Object a has no method 'repeat' ... at [eval]:3:6", being "a" Object a atring (I consoled typeof(c) and it printed "string")
    My line is simply var c = "...." //Assigning a char from a data structure
    ...c.repeat(4);

    Then the error arises.

    Any ideas what could be happen? I tested the code in JS Bin and it works OK

    Thanks!

  • Default User Avatar

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

  • Default User Avatar

    I tried to do in a little improved way of a double for loop, but still timeout.
    What I did is check, for every value of the array, via a eg indexOf(value, pos+1) to see whether a complement value exist, and then save it.
    Sadly still raise a timeout, so the solution is still not fast enough.
    Reading the kata and comments, it's obvious that I have to memoize values, but the problem is that I still don't get how to memoize something in only 1 for loop. I get doing that in simple functions (or recursive), but using recursion will break the stack I guess.
    When you say memoize, how would you thought it? I'm not getting the idea unfortunately.

  • Custom User Avatar

    This comes later than I expected! java translation is ready. Let me know if something is not quite right and I will happily update it.

  • Custom User Avatar

    Per the standard described, dash is 3 time units long and pause between dots and dashes in a character is 1 time unit long. So 11111100111111 look like absolutely correct M, with rate 2. Hmm?

  • Default User Avatar

    Here's one more, apparently the code "11111100111111" should be "M", but for my code is simply a malformed bitcode, as, for being logical, the correct "M" would be "1111110111111" (repeated pattern of same amount of "1"s that transform to a rate = 1, then same for the zeros). How would be the logic with this kind of patterns? (Now I can't just use the rate = 1 to delete the remaining zeros, as there are 2 instead of 1)

    Thanks!

  • Custom User Avatar

    You're welcome! Feel free to ask. :)

  • Default User Avatar

    Yeah, that's waht I did, didn't realized of simply print the bits at the beginning. What puzzled me was the timeout, as, as you said, that could be some internal issue with the page, but it appears that was an unterminated loop or something.

    Thanks for the help.

  • Custom User Avatar

    Well, in fact, no reasonable algorithm for this kata should take seconds to complete. If this happens in your case, you're doing something really, really weird.

    By the way, you can always print the input data of your function to see what the tests are and investigate why their analysis is taking so long.

    Also, after you've managed to pass some of the tests, you may use temporary "shortcuts" in your solution, like "if the test input is this, return that" so that you can move to investigating what is the problem of your code with the next test.

  • Default User Avatar

    Actually I guess it's not that. Reading the comments, with a test like "01110", I'm taking it as a single dot, as the rate is 3 and then there is nothing else.

    For me is not confusion, I'm not confused if is a dot or dash, as for getting the rate I have to read until the next 0 (if there is another way, I didn't get it :P ). Then, using "01110", I'm taking rate = 3 and a single dot, there is no confusion at all.

    My timeout is because (I got it after read the comment), the custom tests have more different cases.

    I think is highly recommended to enter "weird" cases to not get lost with this details, as the timeout should be because my function is not prepared for that cases, as it never ocurred to me something like that (which is my problem, but an extra test would enlighten me :P )

    Cheers!

  • Custom User Avatar

    That happens here on CodeWars from time to time. Try reloading the page first of all.

  • Loading more items...