7 kyu

Cipher

438 of 588bubmet
Description
Loading description...
Algorithms
Ciphers
Cryptography
Strings
  • Please sign in or sign up to leave a comment.
  • Insisted Avatar

    Python Translation Please review ꒰˶> ༝ <˶꒱

  • JohanWiltink Avatar

    Preloaded should not have declarations or definitions of encode and decode. It prevents solutions of the form const encode = "something"; ( which happens to be my favourite ).

    That's not what Preloaded is for, and it's not necessary either. Preloaded should probably simply be empty.

  • JohanWiltink Avatar
    Log
    ʲʠɶʬɶʸʾʲÀɒʈɞʎɞʔʸɶɆÀɞʠʲɶʈʚʔÀʲɶɪʎɆÀɞʠʲɶʈʚʔÀɆʦʾɆÀʂɆʠʠɆÀ˜ɞʸɆÀɆʦʾɆʲ
    Expected: 'spiritus clementia epsilon sigma epsilon aqua kappa zeta aquass'
    instead got: 'spiritus clementia epsilon sigma epsilon aqua kappa zeta aquas'
    

    I'm passing the example tests and then failing all the random tests with an expected value that's one longer than the input and has the last character doubled.

    What's going on there?

    Rectification: The decode tests have the last character doubled, the encode tests have different characters appended. Being illegible scribbles, I unfortunately cannot tell you which ones.

    • bubmet Avatar

      I can't seem to replace this. What code and node version are you using?

    • JohanWiltink Avatar

      This comment has been hidden.

    • bubmet Avatar

      Resolved after fixing the above issue.

      Issue marked resolved by bubmet 7 years ago
    • JohanWiltink Avatar

      I do not see any difference. The other issue seems resolved, so it shouldn't be my refreshing everything.

      Bit premature on the resolve?

    • bubmet Avatar

      Ugh, I swear it worked the first time I tested - I'll try to figure out the cause of the problem.

    • JohanWiltink Avatar

      You're using for .. in without checking if the index is not inherited. I'm defining an enumerable String.prototype method. They combine to create a most fun, most subtle bug. :D

      You should be using for .. of ( or for .. in with Object.hasOwnProperty, or for .. of Object.keys ); I should not be defining an enumerable method.

    • bubmet Avatar

      I see; modified it to use for .. of Object.keys and tested your solution, which works now. :)

    • JohanWiltink Avatar

      rEncode has for .. in Object.keys. I doubt that's gonna work.

      rDecode correctly has for .. of Object.keys.

      The decode tests do too much work BTW. You only need a reference encoder, not a decoder: store the generated solution, encode it, pass it to the user solution, compare its output with the stored solution.

    • bubmet Avatar

      Either in or of would work because the keys and values are both the same as each other, but fixed that too.

    • JohanWiltink Avatar

      It works until I define an enumerable Array.prototype method. :yum:

      Other than that, you're correct of course. :]