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.
OP solved it, closing
this is due to input mutation
Good example; if I can re-publish the kata I will put that in the description. Thanks!
Your code fails for any single digit input (e.g. n=
5
). This is because your reduce function tries to take two arguments (x and y, representing the digits) however the input is one digit long and the second argument doesn't have value, therefore it returns the first value as a string. It produces an error fromm/10
because it is trying to divide a string.Your transformation from string to number does not work.
In the array there could also be negative numbers! Thats the '-'... ;-)
I hope that helps.
All Katas have an automatic discourse page. All you have to do is click the "Discourse" button from the "Details" tab that you start on. Or you can add /discuss in the address bar after the Kata. Here is the link you want: https://www.codewars.com/kata/sorting-on-planet-twisted-3-7/discuss/.
From here you can create your own comment thread (you can give a suggestion, report an issue or ask for help) or you can reply to someone's comment by clicking the "Reply" button.
Welcome to Codewars!
Your code returns string (proof ->
<class 'str'> should equal 0
) when the expected outcome should be an integer. Simply cast the string -> to integer.To post your code in a comment with indentation, use three backticks (`) at the beginning and end of your code - see here for more details.