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.
probably. because the output should be an array of two numerical values, so
"abcd"
is completely unexpected for the tests. GIGO.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Having an unreachable return statement is a general problem; if used with recursion it just means you will not only get erroneous
None
return values, but also the occasional Stack Overflow. In your code: what happens when the recursion stack unwinds back to the original calling function and exits theif
statement. What follows it? Nothing. ErgoNone
.I don't know what inputs you're using locally. It's up to you to follow what path your code takes step by step for any given input. We can't do your debugging for you :)
Please don't post solutions/code in the discourse without the
spoiler
flag.You have a
return
statement nested inside anif/else
clause. This is a code smell. What if theif
clause is always true, when does your code ever returnans
? In Python, a function that doesn't have an explicit return value (or, in your case, an unreachable return statement) returnsNone
by default.I can't tell the solution here. But think if you can first reduce the range. That would be the first optimization. And then see if you're seeing some mathematical pattern.
Yes and by a lot
Yes.
Read Darren1182003's post below.
Are you getting an error, or are you returning something different than the expected? Please be more specific, since I'm on my phone I can't easily check for myself. Thanks!
However, while I agree both answers are symmetrical as per the question, they are not the same. So, you have to fix your code to match the answers on site.
I apologize, I meant to infer that the string had some inversion not reversion, meaning they are not the reverse of eeach other... rather some chars were switched
notice the error message:
so as far I as can tell, your code returns the reverse. do the expected answers on
repl
match the expected answers oncodewars
?Hi, if you post code, especially where indentation matters, please check out using this markdown format to maintain the code.