4 kyu

Vigenère Cipher Helper

3,407 of 8,424jacobb
Description
Loading description...
Algorithms
Ciphers
Security
Object-oriented Programming
Strings
  • Please sign in or sign up to leave a comment.
  • MichaelJF-1 Avatar

    The test for c.encode("it's a shift cipher!") is broken. Actual value for assertion should be "xt'k s ovzii cahdsi!" in Java.

  • Emotes_insane Avatar

    'yiuzsrzheb' should equal 'yiuzsrzhot' i dont get it tf is going on?

  • wilsoncalvache Avatar

    I just had an error and I don't know how to fix it.

    Testing with katakana alphabet Password of 'カタカナ' 'タコタナ' should equal 'タモタワ'

  • PoisonFlash Avatar

    The kata itself was fun to solve. However, I believe that requirements like capability to handle non-sequential alphabets (as katakana from the tests where next character is not always previous + 1) shall be explicit in the description. It is easy to solve but extremely frustrating to figure out. At least it shall be included as an example or a public test case. Otherwise, this becomes "guess what I wanted" type.

  • Mikhail Biriuchinskii Avatar

    It was fun!

    But it's kind of daunting to spend an hour and see that the answer in the solutions is so compact while yours is so long :p

    How do you even come up with those super smart solutions ?

  • mustafaalaliali Avatar

    This kata is not correct. There is an error in the test: Time: 724ms Passed: 1 Failed: 0 Test Results: Log: rovwsoiv CODEWARS

    //This implementation correctly encrypts and decrypts messages using the Vigenère cipher based on the key and alphabet provided.

  • PENA98 Avatar

    expected 'wafflesw' to equal 'waffles', is this correct?, getting this error on the test cases

  • KayleighWasTaken Avatar

    Chai + assert for CoffeeScript

    This also adds Katakana random tests since the only issue I could find with them was Python 2.x specific?

  • c402 Avatar

    I think, this kata is 5 kyu (or even 6)

  • nicolasgutierrezdev Avatar

    Kata tests broken.

  • HartlIKS Avatar

    TypeScript translation (literal translation of JavaScript)

  • Egoistas Avatar

    This kata is broken. When I log decoded message before returning I get correct string 'codewars', but when I run a test I get an error:

    expected 'orrvnqc' to equal 'CODEWARS'

  • Phoenix2816 Avatar

    This comment has been hidden.

  • Goodnato Avatar

    Hi guys,

    This kata have a problem:

    Server Execution Error: Test class name must end with 'Test'. Request Error: Request failed with status code 422 Please fix the issue and try again.

  • Camrebel Avatar

    I belive there is an error in the test cases for JavaScript. My code passes the first test but fails on the second test with a password of pizza. My code gives the correct letters up untill the last 2. I verified the correct answer with a cypeher solver online as well.

  • ManishDhakal2 Avatar

    2 random test cases only show failed

  • Simek98 Avatar

    What is difference between Laint and katakana alphabet?

    It works fine on Latin alphabet so I dont have idea why it doesn't work on katakana

  • Kronifer Avatar

    Some of the tests seem broken, all of them pass but a few

  • BigJam Avatar

    It ran the test c.decode(c.encode('token')) and the expected output was token, the password was 'attackatdawn' and the alphabet was normal. I ran my code in pycharm and it worked and got the right output 'token' but the kata said that an error occurred. List index out of range.

  • Al_1983 Avatar

    PHP Sample Tests are wrong!

        $this->assertSame('CODEWARS', $c->encode('CODEWARS'));
        $this->assertSame('CODEWARS', $c->decode('CODEWARS'));
        
        # Should be:
        
        $this->assertSame('ROVWSOIV', $c->encode('CODEWARS'));
        $this->assertSame('CODEWARS', $c->decode('ROVWSOIV'));
        
    

    My code is case sensitive, but I get:

    testThatVigenèreCipherlsCaseSensitive

    Failed asserting that two strings are identical

    Expected: CODEWARS

    Actual: ROVWSOIV

    All other tests are passed.

  • abyf Avatar

    How are we suppose to handle katakana (Japanese) alphabet? All my tests passed except with katakana alphabet.

  • af_tor Avatar

    A bit tricky, but the Description contains link to Wikipedia, where you can even find JavaScript or Ruby code for the solution.

  • anter69 Avatar

    Forked ruby translation, including new test framework, Ruby 3.0 and a cleaner description -- please check and approve!

  • Najmi Avatar

    i do not know why i keep getting an error eventhough i managed to solve it on my machine. it's just resulting to another word.

  • Your1Chloe Avatar

    My solution passed tests but when comes to test in submit my code during encode goes index out of range at line 46, care somebody to explain me why? I feel hopeless and I dont know what is wrong

  • Kir-1 Avatar

    it was very easy, this should be 8 kata

  • sid114 Avatar
  • n0wht Avatar

    Description is misleading. It says Assume the key is repeated for the length of the text, character by character.. They are not, don't assume that. YOU need to make them the same length.

  • Jessewh Avatar

    Hi - my code is passing all tests except the two javascript ones with the 'pizza' key. -- 'yiuzsrzheb' should equal 'yiuzsrzhot' 'javascrizl' should equal 'javascript' -- any ideas what my issue could be?

  • yLaWy Avatar

    This comment has been hidden.

  • dvub Avatar

    Not too difficult, maybe not a 4 kyu, but I really enjoyed the kata nontheless. Nice one :D

  • Sinimimo Avatar

    I liked this kata. She pushed me to study classes and several other interesting methods to solve it. Although I spent 1-2 hours on it, it seemed to me easy for 4kyu

  • o10g Avatar

    Getting Test class name must end with 'Test'. Even with default code where I didn't change anything.

    After removing character è from the test class name - tests are running and are green. But pressing button Attempt again shows the Getting Test class name must end with 'Test'. error.

    PHP 7.4

  • rrmhearts Avatar

    All my English encodings are correct. And Half of my Japanese encodings are correct. How in the world? Why am I missing four random Japanese words? Could someone review?

  • rrmhearts Avatar

    Everything works in English, passes tests. In katakana, it encodes and decodes to the original! Works amazing, but it won't pass the "test" for katakana. What's up with that? Can someone pass my code?

  • SpokyOky Avatar

    Before php 7.4 % works bad with negative numbers. PHP 8.0 server throws 422

  • user9359099 Avatar

    Nice Kata, but a little easy for 4KYU, imo. It almost requires nothing but simple lang. features.

  • blanktix Avatar

    Almost pass all cases except katakana

  • EarthGround Avatar

    I don't know whether there is an issue with this Kata or an issue with my code but for the Python solution I get the correct answer when I run my code in a different program but when I copy the same code into Codewars, it says I got the answer wrong.

    Examples are: "xt'k o hwixl qzewej!" should equal "xt'k o vwixl qzswej!" "it's a ghift cidher!" should equal "it's a shift cipher!"

  • oceanzhaohai Avatar

    all tests passed except this thit Password of 'カタカナ' expected 'タコタナ' to equal 'タモタワ' what the heck is the shit . I tried just return the str it shows Password of 'カタカナ' expected 'カタカナ' to equal 'タモタワ' is that means PW is カタカナ and is should decode or encode カタカナ to タモタワ? and btw should I do it in the katakana to tamotawa way i mean k convert to t something like that or do it in the Japanese char list way ? coz theres no way Japanese used the abc just like English right? im just simply adding the index of PW str am I doing it wrong ? since others all passed I just cant figure it out

  • alexcodes Avatar

    This comment has been hidden.

  • alexcodes Avatar

    This comment has been hidden.

  • r13doc Avatar

    Hi i have problem with 'pizza' - 'javascript' in python, all test passed but javascript no. Mess. - Traceback (most recent call last): File "tests.py", line 48, in test.assert_equals(c.encode('javascript'), 'javascript') File "/workspace/default/solution.py", line 11, in encode zipped = zip([self.alphabet.index(i) if i.isalpha() else i for i in text], File "/workspace/default/solution.py", line 11, in zipped = zip([self.alphabet.index(i) if i.isalpha() else i for i in text], ValueError: substring not found Could anyone advise me where the problem is? In jupyter 'javascript' with key = "pizza" are 'yiuzsrzhot'. Thanks

  • darkmain Avatar

    No random tests for php.

  • alexalpek Avatar

    Are all the python tests correct? I managed to get all tests right, but 4, where the text was with letters from the katana alphabet. I tried to figure out my mistake, but I ended up with a suspicion that there must be a letter missing from the end of the alphabet or something... Can you confirm that they are all correct? Thanks in advance!

  • Lucasss Avatar

    This comment has been hidden.

  • Nam01ar Avatar

    dont really understand the description shift is derived by applying a Caesar shift to a character with the corresponding index of the key in the alphabet.

    my secret code i want to secure" // message "passwordpasswordpasswordpasswor" // key

  • agray4797 Avatar

    Anyone have any gentle pointers as to why I'm getting IndexErrors for the first two katakana test cases? I've fixed the obvious things, like making sure that the alphabet is correctly ordered and not hard-coding the zero point for the alphabet to be 97. Thanks in advance

  • skooks Avatar

    There are no versions of this available for versions of Node greater than 10. Node v10 has been EOL for over a year.

  • sid114 Avatar

    kind of easy for a 4kyu if you understand how the cipher works still, quite an interesting kata that taught a new cipher!

  • zLuki Avatar

    I was struggling to find out why katana alphabet didn't work. Then I realized that I hard coded 26 as length of alphabet xD

    Great kata!!

  • Tims2007 Avatar

    Hello! Python 3.8 have a problem with: "it's a shift cipher!". My result is "xt'k s ovzii cahdsi!", but in test it's should equal "xt'k o vwixl qzswej!" I've used online calcs to check my variant (for exhample https://planetcalc.com/2468/). Is that issue, or is it only my mistake? Thanks in advance!

  • sadat_saim Avatar

    This comment has been hidden.

  • devmgardner Avatar

    This was an absolute blast to figure out. I sent the description and Wiki article to a friend who said, and I quote, "my eyes are glossing over, what am I reading".

    That being said, it took me like 3 days of work because I wrote the encoding function first, it passed the test suites, and then I realized different alphabets were a requirement. As usual, since I've only been learning Python for a little over a month, my solution is messy as can be.

    Excellent kata!

  • nann1ck Avatar

    I have to say that it's an easy solution for a problem that seems complex when written on paper... nice kata! thanks for the katakana at the end to mess with some beginner's assumptions

  • hannuwilliam Avatar

    This comment has been hidden.

  • Danyrenaudier  Avatar

    doe anyone know why am i getting this return in Js?

    c.decode("rovwsoiv") "codewars"

    c.encode("codewars") "codewarsrovwsoiv"

    It's like it's concatenating the previous answers given...

  • amit970 Avatar

    This comment has been hidden.

  • Yuunooooooo Avatar

    I run my code in my spyder Idle and it encodes "it's a shift cipher!" and decodes "xt'k o vwixl qzswej!" correctly but in here I got the message says "xt'k o hwixl qzewej!" should equal "xt'k o vwixl qzswej!" "it's a ghift cidher!" should equal "it's a shift cipher!" I wonder what's going on. This is from my spyder idle's results "xt'k o vwixl qzswej!""it's a shift cipher!"

  • and-kushnir Avatar

    Interesting Kata!

  • amerr_k Avatar

    There is an issue with one of the tests: Cipher is "xt'k o vwixl qzswej!", key is "password". It says expected output should be: "it's a shift cipher!" but I think the real cipher should be: "xt'k s ovzii cahdsi!" to make output looks like expected. At least my code and criptii site (https://cryptii.com/pipes/vigenere-cipher) says so. Please, correct me if I'm wrong.

  • lgoliveira13 Avatar

    katakana alphabet? seriously? that's why I like this site

  • Moranilt Avatar

    This comment has been hidden.

  • GerryW5510 Avatar

    This comment has been hidden.

  • hochenri Avatar

    I don't understand why I get this error. All the tests were passed, even the ones with the Japanese alphabet. But I get a "list index out of range error" in the test with the Japanese alphabet. How is that possible? How can the test be successfull if I get that error? Besides, I tested the same code on vsc and I get no error with both latin and japanese alphabets.

  • rajat004 Avatar

    how to handle katakana strings?? Anyhelp?

  • mwk48 Avatar

    Learn a lot from tackling with katakana alphabet Nice kata!

  • cpingor Avatar

    This comment has been hidden.

  • sadiq-pasha Avatar

    This comment has been hidden.

  • AlcoBot Avatar

    I'm writing in python 3.6.0 and I have a strange problem. When I press attempt button, in Password of 'password' I have some wrong characters in the last case but when I added same tests in example tests everything is right.

  • a.vadim Avatar

    Hello! PHP 7.4 produces this error:

    Server Execution Error:
    Test class name must end with 'Test'.
    Request Error:
    Request failed with status code 422
    Please fix the issue and try again.
    

    I selected PHP 7.4 because I used an arrow function. When I selected PHP 7.0, all the tests turned green.

  • marcobrx Avatar

    This was a really interesting kata, I just translated it into C++. The way C++ handles Unicode made it a bit more challenging than Javascript (more fun).

  • bigspacerun Avatar

    'asodavwt' should equal 'pancakes'

    key: pizza

    That's all I'm failing on in python. Looking at online encoders/decoders I see asodavwt equals lkpeagou, which is what I get in my code. Only when I change to the variant beaufort cipher do I get "pancakes".

    you can try yourself here https://cryptii.com/pipes/vigenere-cipher

  • ChuangZheQuan Avatar

    I wrote using python 3.6.0.. When running the attempts, I got the wrong answers when password is 'password' and 'pizza' although when running it in JupyterNotebook, I got the correct answers.

    Code in the comments.

  • ChipNeedham Avatar

    Just encountered an issue with test #3 + #4 in PHP, it expects "pncakes" which is wrong, it should be expecting "pancakes"

  • MrOnlineCoder Avatar

    PHP Sample Tests seem to be broken - expected values are missing some letters.

    Example:

    Failed asserting that two strings are equal.
    Expected: 'codeas'
    Actual  : 'codewars'
    

    While sample tests are written as:

    $this->assertEquals($c->encode('codewars'), 'rovwsoiv');
    $this->assertEquals($c->decode('rovwsoiv'), 'codewars');
    
  • Dugimon Avatar

    I'm a bit at a loss. I'm passing most tests (19), but get strange error in the pizza section. I fail when the tests ask to encode 'asodavwt' expecting the result pancakes. However encoding this string produces 'pncakes' and the test fails

    Is this a problem with my code or is there currently a slight typo in the tests?

  • fibonaccios Avatar

    This was one of the best katas I have encountered, it went smooth.

  • jeromemeichelbeck Avatar

    This was... easy...

  • Madjosz Avatar

    Java translation with full random tests.

  • shanoysinc Avatar

    This comment has been hidden.

  • ...JGar Avatar

    I really liked to solve this kata. I pass all tests here except "pizza" with "javascript". But on my console the same code returns the right expectations "javascript => yiuzsrzhot". So is there something wrong with the test? It will be very frustating for other users to solve the kata and not get rewarded.

  • FArekkusu Avatar

    This comment has been hidden.

  • darksithis002 Avatar

    This comment has been hidden.

  • MDabrowski1990 Avatar

    Damn Python 2.7 encodings...

    I have nearly got cancer because of that -_-

  • Shiv  Singh Avatar

    This comment has been hidden.

  • vbevdev Avatar

    Really like this one! It's have a perfect balance between complexity and simplicity. My only suggestion is maybe make description is more explicit? I was need to read the Wikipedia before start because I don't understand how cypher work. Or maybe it's just me.

  • Miss_Evi Avatar

    Solved for everything except the katakana cases (Python)

  • RetroEagle Avatar

    I have trouble with the katakana alphabet... everything else works fine and I have no Idea why that is not working. My first Idea was that one katakana letter is made out of more than one char as python sees it... pls help

  • BAtodl Avatar

    When key ='pizza', both the running sample test and Chrome passed, but attempt failed. What happened?

  • Ludo2406 Avatar

    I translated it for Kotlin ! Can you validate it?

  • challisa Avatar

    Can we open this to Python 3? Sigh

  • coderWarMan Avatar

    I have decoded , encoded and have passed some tests.Why is there such a mistake? test.assert_equals(c.encode('\xe3\x82\xab\xe3\x82\xbf\xe3\x82\xab\xe3\x83\x8a'), '\xe3\x82\xbf\xe3\x83\xa2\xe3\x82\xbf\xe3\x83\xaf') File "/home/codewarrior/solution.py", line 27, in encode num=new_dict[self.key[i]]%26+new_dict[text[i]] KeyError: '\xe3'

  • thefern Avatar

    Would this kata be opened for contributors? I was hoping to translate to swift, and kotlin.

  • thefern Avatar

    I am trying to figure out why my encoding is wrong with 'it's a shift cipher!' my output is = "xt'k s ovzii cahdsi!", but the test says as follows:

    ````xt'k s ovzii cahdsi!" should equal "xt'k o vwixl qzswej!"```

    I ran the same string here https://www.dcode.fr/vigenere-cipher, and gave the same output like mine. xt'k s ovzii cahdsi!"

    If we follow rules for encoding letter a from plaintext to letter s from key, should be encoded to s. The next letter s from plaintext to letter w from key, should be encoded to o. If I keep going by encoding with paper vigenere table my encoding is correct, so not sure what am I doing wrong.

  • u38cg Avatar

    I have a bit of a problem, and I'm scratcching my head a little here. My code passes most of the test cases, inluding the Unicode. Howeer, there's a test case where I don't think I agree with the test:

    The alphabet is abc...xyz, the key is 'password'. The string to encode is "xt'k s ovzii cahdsi!" and the test asserts it should encode to "xt'k o vwixl qzswej!".

    Looking at the first character, frankly, I am struggling to see how "x" + "p" encodes to "x". Am I missing something blindingly obvious?

  • gomezvillegasdaniel Avatar

    All tests passed, but I'm still having the unicode error. What about migrating to python3.6 ?

  • iamnzrv Avatar

    Oh my god! I don't believe i have finally beat damn katakana. Don't forget to decode everything connected with katakana characters and encode your output.

  • sanderd17 Avatar

    This comment has been hidden.

  • narwhaler Avatar

    My program has 22 lines and when submitting I get this. File "main.py", line 39 SyntaxError: Non-ASCII character '\xe3' in file main.py on line 39, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details So, appearently there's something wrong about the backend testing script.

  • abrenon Avatar

    I'm getting the opposite error: output.encode('utf-8') returns a Decode error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 0: ordinal not in range(128)

    I decode all my utf-8 inputs, but it's failing on the last encode.

    (using python 2.7)

  • fatal_strategy Avatar

    Why is Python 3.x not available for this one? At least the supplied strings should be unicode e.g. prefix them with u in the tests, like this: u'カタカナ'. That will make it a 4-character string instead of 12-character.

  • anter69 Avatar

    Updated the example test cases for all languages, increased the number of random tests (where possible), and fixed up the description a little.

  • GregIven Avatar

    This comment has been hidden.

  • Brave_Saw Avatar

    Look like smth is broken. I'm receiving next error:

    it's a shift cipher! <- sequence to be ciphered "xt'k o hhaxp txpzwn!" should equal "xt'k o vwixl qzswej!" <- error message

    The problem is that my code returns "xt'k o vwixl qzswej!" in my local IDE..

  • Gunslinger <RL> Avatar

    I am not sure if it is just me, but the PHP template was missing the fact that the key and alfabeth came through a constructor that was not mention at all. When I got that in place it all worked a lot better.

    Should be part of the start template.

  • fabioquintero Avatar

    In katakana alphabet test, in python the sentence key.decode("utf-8") raise the error: UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-8: ordinal not in range(128)

  • siebenschlaefer Avatar

    There is one test that caused all this grief in Python:

    c = VigenereCipher('カタカナ', 'アイウエオァィゥェォカキクケコサシスセソタチツッテトナニヌネノハヒフヘホマミムメモヤャユュヨョラリルレロワヲンー')
    test.assert_equals(c.decode('ドオカセガヨゴザキアニ'),'ドモアリガトゴザイマス')
    

    I tested all solutions with votes on "Best Practices" or "Clever". All of them failed the final test, except one which handled this test as a special case (if x: return y). This special case handling is also done in all of the newest 50+ solutions.

    The most vexing part is that you can copy the tests into the sample tests of the kata trainer, click "Run Sample Tests" and all tests pass. You can also click "Validate Solution" in the Kata Creator and all tests pass. But when you click on "Attempt" in the kata trainer, that one problematic test fails.

    With some monkey patching I could confirm that in the sample tests 'ドモアリガトゴザイマス' is passed (correctly) as

    '\xe3\x83\x89\xe3\x83\xa2\xe3\x82\xa2\xe3\x83\xaa\xe3\x82\xac\xe3\x83\x88\xe3\x82\xb4\xe3\x82\xb6\xe3\x82\xa4\xe3\x83\x9e\xe3\x82\xb9'
    

    but on an Attempt it is passed as

    '\xe3\x83\x89\xe3\x83\xa2\xe3\x82\xa2\xe3\x83\xaa\xe3\x82\xac\xe3\x83\x88\xe3\x82\xb4\xe3\x82\xb6\xe3\x82\xa4\xe3\x83\x9e\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd'
    

    I have no clue what's going on. To fix this kata I have replaced all literal katagana strings with manually UTF-8 encoded strings. I tested some of the accepted solutions and now they pass again.

  • stuxnet Avatar

    The katana alphabet makes it impossible to do it in python

  • stormhaul Avatar

    Tests are set up improperly in PHP.

    By printing out the start states for the tests I can recreate them in my preview tests and pass them all, but I fail on the main:

    Example: First test key: password alphabet: abcdefghijklmnopqrstuvwxyz string: codewars Should expect: acosaecs Real Test: Failed asserting that two strings are equal. Expected: 'acosaecs' Actual : 'rovwsoiv' even though prints of my return value show I'm returning acosaecs not rovwsoiv.

    Seems as though you've hardcoded the response....

  • fdljasd Avatar

    I believe it might be a good idea to update the Python version of this Kata to Python 3 in order to ease the Unicode handling.

  • kjmosher Avatar

    To everyone who has seen the issues with Python 2.7.6 and the Katakana tests:

    I am not the original author, but my rank allowed me to attempt to edit the Kata. When I did so, the test cases look absolutely correct.

    I ran the original author's solution against those cases, and they all pass without any sort of hack.

    I copied in my own solution code, without the hack for test # 20 that allowed me to submit my solution ... and it passed the tests.

    It seems as though there's a difference when the test cases are run in the Kata authoring editor, versus running them in the training editor.

    I will report this to the admins.

  • youngfeldt Avatar

    Remove python as a language choice or remove the failing python test. Really lame to leave broken for a language you have listed.

  • tramee Avatar

    Hello, when trying to pass the Katakana tests, I have an error on the fourth or fith test. However, the output of my code is ドモアリガトゴザイマス (which looks valid) and the expected string is ドモアリガトゴザイマ��� which seems invalid to me. Am I missing something?

  • hhummel Avatar

    Rewrote my Python solution in Javascript and worked without drama. Still unclear what the issue is with the Python version, but I recommend solving it in a different language.

  • sebastian-nowakowski Avatar

    Katakana tests for python still seem to be messed up.

  • hhummel Avatar

    I seem to be in the same hole everyone else is: failing on test 20 after lots of python 2.7 unicode jiu jitsu.

    '\xe3\x83\x89\xe3\x83\xa2\xe3\x82\xa2\xe3\x83\xaa\xe3\x82\xac\xe3\x83\x88\xe3\x82\xb4\xe3\x82\xb6\xe3\x82\xa4\xe3\x83\x9e\xe3\x82\xb9' should equal '\xe3\x83\x89\xe3\x83\xa2\xe3\x82\xa2\xe3\x83\xaa\xe3\x82\xac\xe3\x83\x88\xe3\x82\xb4\xe3\x82\xb6\xe3\x82\xa4\xe3\x83\x9e\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd'

    I can't tell if other people got past this or how to push on. Is it just me?

  • atleta Avatar

    This comment has been hidden.

  • tevans Avatar

    I think there's something wrong with the final test (the Japanese one) for Python.

    • Every character in the alphabet, key and input message takes 3 bytes
    • The message to decode is "ドオカセガヨゴザキアニ" - 11 characters == 33 bytes
    • The test fails, saying it expects '\xe3\x83\x89\xe3\x83\xa2\xe3\x82\xa2\xe3\x83\xaa\xe3\x82\xac\xe3\x83\x88\xe3\x82\xb4\xe3\x82\xb6\xe3\x82\xa4\xe3\x83\x9e\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd' - 39 bytes
    • The last 9 bytes represent the same character 3 times - apparently \ufffd, unicode's "replacement character"!

    Please fix the test / explain why I'm wrong... I want to complete this kata!

  • ThatCob Avatar

    Hey, just wondering whether I'm misunderstanding something or there's an error in the Python test cases? I keep passing all the tests but getting this issue:

    Traceback: in in encode ValueError: "'" is not in list

    I messed around with my own test cases and found I got the same error when I set up the password key as "'password'" instead of "password". So I used key.strip("'") to get rid of the ' but I'm still encountering the error.

  • jamesriley101 Avatar

    Man why don't you just change the testing suite for Python?

    Great Kata but very frustrating to get through it and get stopped by utf-8 encoding bugs in the tests.

  • CraigLangford Avatar

    (Python 2.7) I can't get one of the Katana tests to work. My output makes sense, however, the desired output from the test is requesting a longer string than the input.

    Key:     カタカナ
    In:      ドオカセガヨゴザキアニ
    My out:  ドモアリガトゴザイマス
    Desired: ドモアリガトゴザイマ���
    
  • cowsareinme Avatar

    I'm having a problem that I don't understand. After wrangling with the unicode conversion for a while, I have results that are mostly right, but a couple of characters are off. '\xe3\x82\xbf\xe3\x82\xb3\xe3\x82\xbf\xe3\x82\xa2' should equal '\xe3\x82\xbf\xe3\x83\xa2\xe3\x82\xbf\xe3\x83\xaf'. Specifically, what should be \x83 is being encoded as \x82, even though there is a properly encoded \x82 character. The majority of the characters being correct makes me think my logic is correct, but I'm still encountering a unicode bug somwhere. Any insights would be greatly appreciated!

  • Madrox Avatar

    This comment has been hidden.

  • __TomFoolery__ Avatar

    keep passing 20 only failing at one, I think my code is good and the problem may be in the test cases I could just write into it if this line "???? then this line ??? but I dont want to half ass it can someone check there code that has passed it and get back to me I think it is the 21 subission yests case that has error In python I keep forgetting each languages has differenct code for test cases, see if your python code is working if it has worked befor thanks in advance

  • user2414950 Avatar

    As dimmk0 and gabbek explain in the Questions section, the last test is failing despite having the correct answer.

  • yiyuezhuo Avatar

    I write Python first and fail a lot of times, I spent lot time to debug it and copy raw code in local to test it. I think of the last test case have encode error. I am confused why 100+ pass Python version? Are they mapping its wrong answer specially? Anyway I give up Python and choose JavaScript to pass it to check those test case.

  • dimmk0 Avatar

    Hi, one test with katakana is failed. I have add some debug lines to trace, and what I see? Test string is successfully decoded! But test failed for some reason. Whats wrong?

    String to encode : ドモアリガトゴザイマス, length: 33 encoded : ドオカセガヨゴザキアニ, length 33
    ✔ Test Passed
    String to decode : ドオカセガヨゴザキアニ, length 33 decoded : ドモアリガトゴザイマス, length 33
    ✘ '\xe3\x83\x89\xe3\x83\xa2\xe3\x82\xa2\xe3\x83\xaa\xe3\x82\xac\xe3\x83\x88\xe3\x82\xb4\xe3\x82\xb6\xe3\x82\xa4\xe3\x83\x9e\xe3\x82\xb9' should equal '\xe3\x83\x89\xe3\x83\xa2\xe3\x82\xa2\xe3\x83\xaa\xe3\x82\xac\xe3\x83\x88\xe3\x82\xb4\xe3\x82\xb6\xe3\x82\xa4\xe3\x83\x9e\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd'

  • donaldsebleung Avatar

    PHP Translation Kumited - please accept :D

  • dcrystalj Avatar

    '\xe3\x82\xab\xe3\x82\xbf\xe3\x82\xab\xe3\x83\x8a' should equal '\xe3\x82\xbf\xe3\x83\xa2\xe3\x82\xbf\xe3\x83\xaf' what is this problem encoding issue or bug? For me this is python nightmare kata. To much encoding jokes.

  • wurstl Avatar

    Instructions are still not mentioning which Unicode encoding to expect. (It seems to be UTF-8.)

  • dongocdc70 Avatar

    2 minutes to write the code. 2 hours to solve the unicode conversion. upgrade to python 3 please :(

  • donaldsebleung Avatar

    The encryption was quite easy and straightforward but the decryption was a bit tricky ... anyway, great Kata, loved it <3 :D

  • flatline Avatar

    man, seriously what's wrong with you... no mention about the unicode part.... totally wrong description!

  • Strad Avatar

    Python - my code works in the initial tests, but on hitting submit:

    Testing with lowercase latin alphabet Password of 'password' Traceback: in in encode NameError: global name 'key' is not defined

    Are the tests initiating the test data correctly?

  • stnmonroe Avatar

    This comment has been hidden.

  • russh Avatar

    If you want to make a kata about unicode conversion, then make one that is about unicode conversion. Or at least have the decency to mention it in the instructions. A**hole

  • xim Avatar

    Kata does not specify that unicode data will be passed. Specifying in description that input is utf-8 encoded bytes, and that decryption should be performed per decoded symbol and not per byte, would be helpful. =)

  • Ryoda Avatar

    katakana why you hate me so much D:

  • rick14 Avatar

    How come 'ilxfpwv' should equal 'waffles' with the key being 'password'? (Python)

  • liumx10 Avatar

    I try to transfer code to "unicode" by: key = key.decode("utf-8") the result is UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)

    But it work well on my computer. with python 2.7. Does anyone know why?

  • cjmochrie Avatar

    This comment has been hidden.

  • omgimanerd Avatar

    This comment has been hidden.

  • forbiddenvoid Avatar

    Oy. Unicode with python. Still, lots of fun. I liked it!

  • paceaux Avatar

    this was a really fun Kata. seemed a little easy for a 4 Kyu kata, though.

    The description of the cypher was a little confusing though. I had to go to wikipedia and read the page to really understand how the cipher worked.

    Maybe if it explained the cipher something like:

    A Caesar cipher shifts all letters in the string n spaces. A Vigenère cipher shifts each individual letter in the string n space, where n is calculated as "index of the original letter in the string + index of the letter in the key"

    A Caesar encrption can use a shift value of 3, turning 'dog' (3,14,6) into 'grj' (6,17,9) But Vigenère uses the key 'pup' (15,20,15) to turn 'dog' (3,14,6) into 'siv' (18,8, 21).

  • ToshiCG Avatar

    I am getting "Process was terminated. It took longer than 6000ms to complete"... My solution which worked for the simple testcases relies on arrays. Is that the problem?

  • ZijianHe Avatar

    I just cannot go through the 5th test in katakana using python and don't know how to figure it out. Will there be any hint?

  • jake-jake-jake Avatar

    This comment has been hidden.

  • DavidWinterbottom Avatar

    I don't think the level is correct - this isn't a 4kyu kata.

  • godescbach Avatar

    I'm almost there, but I can't figure out how to properly index into a multibyte string to get a multibyte char. I can manually verify the correct solution provided by the output for the katakana test. And I am getting the write indices into the katakana alphabet for the encoded message. However, I can't properly build the string from the katakana alphabet, encoded += alphabet[idx] only gets 1 byte (should be 3). I have yet to find any useful examples of such indexing on the internet. I would greatly appreciate any hints, pointers and/or references.

    Thanks.

  • coralv Avatar

    I'm stuck on the katakana section. When I look at the alphabet, everything seems fine (it even prints in katakana), but things go funny when printing out my tabula recta. This is the first line, which should just be the alphabet in initial order:

    ['\xe3', '\x82', '\xa2', '\xe3', '\x82', '\xa4', '\xe3', '\x82', '\xa6', '\xe3', '\x82', '\xa8', '\xe3', '\x82', '\xaa', '\xe3', '\x82', '\xa1', '\xe3', '\x82', '\xa3', '\xe3', '\x82', '\xa5', '\xe3', '\x82', '\xa7', '\xe3', '\x82', '\xa9', '\xe3', '\x82', '\xab', '\xe3', '\x82', '\xad', '\xe3', '\x82', '\xaf', '\xe3', '\x82', '\xb1', '\xe3', '\x82', '\xb3', '\xe3', '\x82', '\xb5', '\xe3', '\x82', '\xb7', '\xe3', '\x82', '\xb9', '\xe3', '\x82', '\xbb', '\xe3', '\x82', '\xbd', '\xe3', '\x82', '\xbf', '\xe3', '\x83', '\x81', '\xe3', '\x83', '\x84', '\xe3', '\x83', '\x83', '\xe3', '\x83', '\x86', '\xe3', '\x83', '\x88', '\xe3', '\x83', '\x8a', '\xe3', '\x83', '\x8b', '\xe3', '\x83', '\x8c', '\xe3', '\x83', '\x8d', '\xe3', '\x83', '\x8e', '\xe3', '\x83', '\x8f', '\xe3', '\x83', '\x92', '\xe3', '\x83', '\x95', '\xe3', '\x83', '\x98', '\xe3', '\x83', '\x9b', '\xe3', '\x83', '\x9e', '\xe3', '\x83', '\x9f', '\xe3', '\x83', '\xa0', '\xe3', '\x83', '\xa1', '\xe3', '\x83', '\xa2', '\xe3', '\x83', '\xa4', '\xe3', '\x83', '\xa3', '\xe3', '\x83', '\xa6', '\xe3', '\x83', '\xa5', '\xe3', '\x83', '\xa8', '\xe3', '\x83', '\xa7', '\xe3', '\x83', '\xa9', '\xe3', '\x83', '\xaa', '\xe3', '\x83', '\xab', '\xe3', '\x83', '\xac', '\xe3', '\x83', '\xad', '\xe3', '\x83', '\xaf', '\xe3', '\x83', '\xb2', '\xe3', '\x83', '\xb3', '\xe3', '\x83', '\xbc']

    I don't know why it no longer prints in katakana. Not only does that seem weird, but the symbols in this first line look like they're repeating in a very strange fashion. For example, "\xe3" seems to show up 56 times in a given alphabet which appears to have only 60 characters. How can that be?

    When I build each line of my table, I just do line.append(self.alphabet[counter]). Even printing out a single character from the alphabet by doing "print self.alphabet[0]" gives me something other than katakana. Can someone help me see what's going wrong here?

  • adam-tokarski Avatar

    I've just added a Python translation, waiting for approval!

  • oldccoder Avatar

    Good one, a nice teacher for basic (old, historic) encryption practices. I accidentally hardcoded a 26 for the alphabet size instead of using abc.length, and could not find my error for awhile. Silly me...

  • ronanyeah Avatar

    This comment has been hidden.

  • IVBakker Avatar

    Any hint on how to handle the katana' alphabet? I tried to use the "abc" provided in input as the alphabet used. Thus the first letter would be the zero reference and the last letter the end reference. But it doesn't work. I can't find where are these damn chinese character on the asci codes.

    I think I'm having issues with the capital/non capital letters.

  • c89williams Avatar

    You should really add in the description that you will be testing against Unicode characters (the katakana alphabet test cases). That really messed me up, had I known before hand I would have coded it differently.

  • adlen Avatar

    Fun kata, I enjoyed it!

  • rooc Avatar

    worthy kata!

  • jacobb Avatar

    Added a CoffeeScript version.

  • jacobb Avatar

    Omg, laoris is working on my first published kata. I hope the person is creative in his/her hello world sense more than in his/her block of code sense.

  • jacobb Avatar

    This comment has been hidden.

  • OverZealous Avatar

    The example test code is missing the y in it's alphabet, causing errors where there are none.

    Edit: Otherwise, this is a decent kata!