7 kyu
Alphabet symmetry
3,946 of 15,248KenKamau
Loading description...
Strings
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Very fun kata, thanks!
python new test framework is required. updated in this fork
.
Python new test framework required.
More details here and here
done
Thanks, updated
In Python,
test.assert_equals(solverMX51(L), solve(L))
should be written astest.assert_equals(solve(L), solverMX51(L))
in random tests. You are using the 'user' solution as the 'expected' solution.Done
Nim translation have 3:
Unhandled exception: key not found: { [KeyError]
it seems everything was fixed by this fork
Note for nim version - cannot run my solution, says "unauthorized" :/
https://www.codewars.com/kumite/643e62e0287bf70054bc3f7d?sel=643e62e0287bf70054bc3f7d
Fork with test update for node v18 :)
approved
nice kata!! Thanks Ken
Great Kata, thank you KenKamau! The only thing is, I should upgrade it to level 6, imho ))
This comment has been hidden.
it's sad, you were just missing the letter
q
inalphabet
. Note that you could have usedascii_lowercase
from thestring
module ;-)well done! Creative kata
Nim translation fixes
fixes:
Please approve!
approved
String index out of range: 26 ??
nvm solved
This comment has been hidden.
please use understandable englsih
COBOL translation.
One test case was duplicated. Fixed and made a fork.
Approved, thanks!
Missing return type in initial solution of TS
I tried to fix it in this fork, and added type to other functions used within the tests, please review and approve if it's ok: https://www.codewars.com/kumite/5d4cf1a9b35c66001fbd4a75?sel=625ab199a071210017c8a6a1
added + made the initial code compile
C translation
Approved :)
Updated Dart translation (Dart 2.14).
Wooooow! Great!
A very good Kata
Tests were a little bit different than description, that makes me sad face instead of smiley face but thank you for the Kata!
C++ fork related to this issue.
Thanks, approved ;-)
C++ version compile warnings need to be fixed (see https://github.com/codewars/content-issues/wiki/List-of-Cpp-Kata-to-Update).
;-)
This comment has been hidden.
Not a kata issue, please read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution
Input string can be longer than your alphabet.
All tests until the exit code, there are more tests.
Very good Kata!!
Julia translation
Thanks
For c++ this cata has a warning, which should be fixed:
main.cpp:36:23: warning: comparison of integers of different signs: 'int' and 'std::__cxx11::basic_string<char, std::char_traits, std::allocator >::size_type' (aka 'unsigned long') [-Wsign-compare] for (int i = 0; i < s.size(); i++) { ~ ^ ~~~~~~~~ 1 warning generated.
(not my code, kata code)
I'm rather new here but I've recieved feedback that you should tag such a comment as an issue
This comment has been hidden.
'alr approved some time ago'
Prolog translation.
Thx
Very balanced kata, quite original too. Love it.
The Pyton translation seems to have some issues. In the random rests I have noticed that:
1 - Some expected values are higher than the amount of characters in the corresponding string. 2 - Some expected values are higher than 26. 3 - The wrongly expected values seem to be always double the actual value. 4 - It seems to only be calculated wrongly when all characters are in the same place as in the alphabet, but not always! (Not 100% sure since it is hard to sift through all the numbers, but it seems to look that way)
can provide more info if needed, just tell me what you need!
More than 1000 correct Python solutions.
Please provide example of bad test.
This comment has been hidden.
Thanks
I made a Screenshot so you can see a bit easier that there is definitely a problem. If you're interested, I can upload it and send you a link.
Thanks for your reply, btw!
This kata wonts you to Return, for each word, the number of letters that occupy the same positions as in the alphabet.
Signature of "solve" method "public static int[]" mean that method must return integer array, but when kata start you can see incorrect return type "return new String[0]".
public class Solution{ public static int[] solve(String[] arr){ // do your thing return new String[0]; } }
Fixed
Since the problem says "letters", shouldn't you try to trick people with non-letters? For example, "z' could be in the 26th position, and "{" in the 27th position. Then try the same with upper case: "Z" in the 26th position, and "[" in the 27th position.
Some solutions pass despite ignoring the alphabet.
Good idea, though too late. Too many solutions have passed for tests to be changed now.
Too many solutions have passed for SPECS to be changed now.
No symbols.
This comment has been hidden.
Can you paste here the test that you are failing? It looks like you are trying to access an element outside the string length.
This comment has been hidden.
You can use a print statement at the top of your code.
It seems there are strings longer than the alphabet in the tests, as I suspected, but I'm not really sure what should I do. I passed the test but I'm filling kind of dirty because I didn't know what I was expected to when a word longer than the alphabet was in the array. I'll look to others solutions now that I passed and try to figure it out, but thanks for your help anyway!
This comment has been hidden.
This comment has been hidden.
You don't specify what went wrong. Which test case did you fail on, and what output did you see from that failure? (If it's a stack trace, the first 1-2 lines are enough).
Go translation, please check and feel free to approve or reject it!
Thanks. Approved.
CoffeeScript translation Dart translation PHP translation TypeScript translation
Thanks. Approved.
I have a problem with the last test. Following error is comming up at the final test: 'Reduce of empty array with no initial value'. I tried to modify the input with
Array.slice(0)
but it doesn't work. I'm sure that it will work with any random test. What's wrong with this kata?reduce
isn't used in the solution so I guess you're using it in your code (and you're not setting an initial value and using it on an empty array), can't tell you more without seeing it.This comment has been hidden.
No, the solution would be using an initial value. MDN Docs about reduce.
Works, thanks.
JS I pass the basic tests then get feedback like below for the random tests. At the very least, the error message needs work as clearly an empty array is not expected.
[ 'ABCabcdef', 'ABCabcdefg', 'ABCDabcdijklmnopqrs', 'ABCDEFGHabcde', 'ABCabcghijklmnopq', 'ABCdefghijkl', 'ABCDEFGHIabcdeop', 'ABCDEabcdefghi', 'ABadefghi', etc. etc.
It should work for random inputs too - Expected: [], instead got: [3, 3, 15, 8, 14, 12, 11, 5, 8, 20, 18, 14, 7, 9, 7, 21, 16, 5, 16, 18, 20, 4, 6, 7, 1, 13, 6, 21, 22, 14, 5, 16, 13, 24, 19, 17, 14, 4, 9, 11, 5, 15, 15, 14, 3, 6, 5, 7, 14, 12, 4, 6, 6, 6, 19, 12, 11, 9, 3, 13, 23, 6, 21, 13, 9, 7, 2, 7, 22, 12, 23, 9, 1, 2, 9, 5, 15, 17, 4, 20, 16, 15, 8, 17, 9, 7, 9, 12, 10, 6, 9, 8, 6, 8, 7, 4, 9, 14, 4, 22, 9]
Can anyone help me with this? As far as I can see my result is correct.
Try again and see if it works now.
If it doesn't, first make a copy of the input array using
Array.slice(0)
then use this array in your code.Weird, it doesn't seem possible to mutate the input and affect the test suite.
Thanks. Array.slice(0) made it work.
This comment has been hidden.
same problem here, Array.slice(0) DOES NOT SOLVE THE ISSUE
Issue? Hardly. If you can't solve it, you can't solve it.
My solution fails the random test. Can anyone please tell me what this test does? Regards!
You can insert a print statement see what the input is.
Oh! great! Thanks!
With the print statement I see:
AxcXUzBhIckETEoHdrstUsw
Expected: equal to [ 11] Actual: ¿¿[ 9]?? This is not true, right? My solution of 11 is ok, right?
Expected is
11
. Your result is9
.Which language?
Fortran Translation Kumited - please accept :D
This was a really fun kata, thanks for making it :)
Can you please try again to explain what you are looking for? I simply do not understand what is asked here...
Return, for each word, the number of letters that occupy the same positions as in the alphabet.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
It seems some string in the array is longer than your alphabet.
IndexError: string index out of range
I got the same error but none of the strings tested were longer than my alphabet (24 characters imported from string.ascii). Try using the following expresion when defining your alphabet:
alphabet = 'abcdefghijklmnopqrstuvwxyz'*2
There might be indeed a string somewhere during submission which is indeed longer than you standard alphabet. So attribute the aphabet twice or evem attribute a lot of "z" characters at the end:
alphabet = 'abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzz'
c++ translation submitted as well :)
thanks, but you haven't published it yet! Do you want me to publish then approve?
Mh, didn't save: try this :)
P.S.: so you can publish translations of other authors?
Could please anybody explain ("encode","abc","xyzD","ABmD"]),[1, 3, 1, 3]) more detaled! How e==1, c==3(ok, its 3d order of abc), x==1, m==3 ???
For "encode", only letter 'c' is in its position in the alphabet. So return 1.
For "abc", all 3 letters are in the right position. So return 3.
For "xyzD", only 'D' is is in the right position, because it is the fourth letter of the alphabet and it is fourth in this string.
Resolved
thanks a lot!
Damn loving your katas :D
Many thanks. Nice solution!
I made a C# translation for this Kata.
Approved. thanks.
For those using a string representing the alphabet, remember that characters also represent numerical values! You can make your solution up to 26 times faster by just using some arithmetic.
http://www.asciitable.com/
This comment has been hidden.
Can you post the failing test?
This comment has been hidden.