Ad
  • Custom User Avatar

    I just published the R translation of this Kata.
    Please, check it out and comment or approve it.

    It is my first Kata translation, so I am open to any constructive criticism.

  • Custom User Avatar

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

  • Custom User Avatar

    In R, only a few libraries can be loaded in the soluntions, and non of them contains a function to test prime numbers or factorize numbers. So, I wrote my own code. It works but it runs out of time.

    Any suggestions or tips to beat the clock?

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    I don't do R, sorry. But are you sure your code is O(n)? Try posting it following this, and I (or someone else) will take a look at it.

  • Custom User Avatar

    Let me rephrase. I know it's solvable. Do you have any suggestions to optimize O(n) code in R? I am unsure which operations are more time consuming or if I should use a particular package

  • Custom User Avatar

    R Completions 81

  • Custom User Avatar

    I run out of time with this kata in R. I am pretty sure my code is O(n), but I got stuck at approx. 54 test cases. Suggestions accepted!

  • Custom User Avatar

    Got it! Thanks mate

  • Custom User Avatar

    The Morse code table is preloaded for you as a dictionary, feel free to use it:

    Coffeescript/C++/Go/JavaScript/Julia/PHP/Python/Ruby/TypeScript: MORSE_CODE['.--']

    ^ That dictionary. You're passing '' as a key to it.

  • Custom User Avatar

    Can you please elaborate further? I do not define any dictionary in my solution, which contains only a list within the function scope and returns a string. I think the definition of the problem does not request any dictionary

  • Custom User Avatar

    No, that's a problem with your code, not a kata issue. You're passing a key to the dictionary that doesn't exist.

  • Custom User Avatar

    I think there is an issue with tests in Python. My code passes all tests, but I get a STDERR message:

    Time: 508ms Passed: 10 Failed: 0 Exit Code: 1

    Test Results:
    Example from description [...]
    Basic Morse decoding [...]
    Extra zeros handling [...]

    STDERR
    Traceback (most recent call last):
    File "/workspace/default/tests.py", line 30, in
    testAndPrint(decodeMorse(' . . '), 'E E')
    File "/workspace/default/solution.py", line 11, in decode_morse
    msg += MORSE_CODE[char]
    KeyError: ''