Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Look at the example, your code needs to extend the key as needed. You've added the failsafe to encode, but not to decode method.
Why am I getting this error?
Traceback (most recent call last):
File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper
func()
File "/workspace/default/tests.py", line 19, in it1
test.assert_equals(c.decode("xt'k o vwixl qzswej!"), "it's a shift cipher!")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/default/solution.py", line 29, in decode
new_index = alphabet.index(text[i]) - alphabet.index(key[i])
~~~^^^
IndexError: string index out of range
Shouldn't the key be the same length as the text to encode, meaning that if text[i] exists then key[i] exists? I added a failsafe while loop:
while len(text) < len(key):
key = key + key
and still get the error. Thanks for any suggestions!
How am I supposed to handle multi-byte katakana, especially given that test cases are called with key="" alphabet=""?
And the fixes have been merged, thanks tor letting me know!
Should all be good now, thanks for the reports!
Here is a fork that addresses the issue; someone still needs to approve it though.
this is just beautiful...
MErged.
Confirmed; I published a fork to fix this.
Thanks for the report! I had based the generator on the C++ translation but I can see now that the alphabet selection is indeed incorrect. I'll see about getting this fixed ASAP.
Update: I published a fork with a fix, it just needs a review to go live.
Alphabets are now generated using sampling without replacement.
??
Whenever encode or decode is called, my code prints in order input string and output string..
I Will check.
but... doesnt explain the output auab^... of the expected value ??
can't verify due to not having solved in c++/not seeing your code
but - this looks to me like you're mixing up different test cases, ie. you're showing the input of one test and the expected output of a different one. be careful with how you print and how you read the output.
See above, Go tests seem to have a problem. I have tested some of them with my Python code and I get the same results as my Go code.
For instance:
Encode Key: OZzhEOAUlkOZDh Alpha: ckclVDAJzUsohOEJZQVDw Text: kZOlaAosDQbUE10FcO
My answer: EocJaDQDzVbVD10FzV Expected answer: EocJaDQDkVbVh10FsV
Haha, I just came here to say something is wrong with the Go tests.
This comment is hidden because it contains spoiler information about the solution
Loading more items...