Ad
  • Custom User Avatar

    Please, mention the language you're talking about, there are many for this kata. If it is Python, this is the initial code:

    def decode_bits(bits):
        # ToDo: Accept 0's and 1's, return dots, dashes and spaces
        return bits.replace('111', '-').replace('000', ' ').replace('1', '.').replace('0', '')
    
    def decode_morse(morseCode):
        # ToDo: Accept dots, dashes and spaces, return human-readable message
        return morseCode.replace('.', MORSE_CODE['.']).replace('-', MORSE_CODE['-']).replace(' ', '')
    

    As you can see the names of both functions are ok. Only the var morseCode is using camelCase and should be changed to snake_case. Now, if you talk about the kata description, yes, they are both named in camelCase and the description is shared amongst all languages.

  • Custom User Avatar

    Interesting! The program shouldn't indeed rely on the user not changing the inputs. I updated the code, passing copies of the deck instead of the original array. Thanks for your help :-)

  • Custom User Avatar

    Haha :-) That is awesome! An actual real usecase of the algorithm, I'm a fan :-) Just sent you a message, the password is playingcards ;-)

  • Custom User Avatar

    I did the translation... but I'm not a Python dev so it's almost a "literal" translation from Java, absolutely not in the Python style. It was three years ago and I didn't touch Python at all since then. So I won't be able to help you further I'm afraid.

    Altough, I'd be happy to give you the Python solution. So you'll be able to understand where the problem is, and if it's with the Codewars solution, please report it back so we can correct it :-)

    I guess if I post it here and mark it as spoiler, you won't be able to see it, so if you give me a link to your public PGP key, I'll encrypt it for you. (https://www.gnupg.org/gph/en/manual/c14.html)

    Already 23 people solved this kata in Python though, so it would be a bit surprising if has an error...

  • Custom User Avatar

    Thanks B4B ;-)

    Hey tranquility-base, have you succeeded to make your code work? I'm not fluent in Python, and if you say it works, I don't know where to look...

  • Custom User Avatar

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

  • Custom User Avatar

    I feel the same about the C# version. I'm not sure when the program is supposed to exit. It passes some tests if it exists when it's processed all the input but not others.

  • Custom User Avatar

    python: test.assert_equals(user, expected)
    java: assertEquals(expected, user)

    (reminder)

  • Custom User Avatar

    Hi,

    I confirm that this deck is valid, and it decodes to "ABCTBIPRWRCKCLVR RZLZLRSZYAQ ZPERPLP OOJQUANHA V", as you wrote.

    Are you sure your code isn't decoding to None? (Test libraries are annoying, when you write test.assert_equals(a, b) for instance, you never know if a should be the user's value, or the one it's tested against. I just checked, we should be good here, but better make sure.)

    Cheers

  • Custom User Avatar

    Thanks, I'm surprised. Never heard that there was a confusion between the two.

  • Custom User Avatar

    "the A B Cs"
    And the first letter is never a capital in camelCase.

  • Custom User Avatar

    The first value is not the input, it's what your code returned (and you can see it hasn't all zeroes at the end, so it is wrong). The tests are ok, not a kata issue. Fix your code.

    Python Completions 9714