6 kyu
Single character palindromes
727 of 2,133KenKamau
Loading description...
Algorithms
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.
python new test framework is required. updated in this fork
Approved
C#: method name should be
PascalCase
(Please refer to implementation of backward compatibility here )C Translation
Very nice Kata, thank you :) No problem with tests.
I have a solution, but in the Random test doesnt work well. All basic test work well,and IntelijIdea work well with random words.
Did you try in your IntelliJ exactly the same words which fail on CW? If you don't know how to check what words cause your solution to fail, read this paragraph of FAQ.
Basic tests all correct,but random tests are failed.
Did you try to test inputs from random tests? Print the input for that.
I have a solution, but in the Random test doesnt work well.
In jupyter notebook whatever , work well... With random words!!!!!! Why?
Pick one (or more):
a) it does not work because it's wrong b) we don't know why it does not work, because we did not see your code c) it works in Jupyter because you test it with other words than CW random tests use
Using python, can expressions not be used for slice indices? I understand expressions can be used wherever values can also be used
like so, trying this in my solution to check if string is already a palindrome: if s[:len(s)/2 + 1] == s[len(s)/2:]: return "OK" I get: "TypeError: slice indices must be integers or None or have an index method"
The answer is in the error message, depending of the length that number can be a float.
ah, i see, it returns a float by default within that context, thanks
I'm using Javascript, and my code passed the initial tests, but when I go to attempt the kata, I get a bunch of fails. The issue is that all the ones I looked at gave what should have been the correct answer, but it was telling me it was wrong/expecting the wrong answer.
This also happened with one of the initial tests, which was expecting the wrong answer; that tripped me up for quite a while.
Please, provide the input, actual and expected values of the tests you think are wrong, otherwise this issue will be closed as there is no proof of it being an issue. Note there are 353 solutions in javascript already.
Just solved the kata in javascript, there is no problem with the tests, the problem is in your code, read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution
I just realised my problem; seems I slightly misunderstood the instructions. Sorry for the confusion.
I'm a bit confused. I am running these tests that I fail on my same code in Jupyter and it returns the correct response but here I seem to get a response that isn't correct / aligned with what I got in my own testing outside this site... any thoughts?
for example in jupyter: solve("abcdba") 'remove one'
but here the same code gives: 'not possible' should equal 'remove one'
I keep failing this one edgecase and then a handful of random tests. they all work in jupyter tho so I'm at a lose here
This is in Python, right? I'm assuming you're referring to
abc_ba
not being recognized as a palindrome? That's strange.correct, in python. Yea, i'm not sure tbh. This is one of the few katas where my code works in jupyter but not here so I'm at a lose
The test is as follows:
The correct answer is remove one, as you have pointed out
I don't see an issue here.
@Ken hey I actually managed to figure it out. I'm sure you'd never guess it but my code was wrong Sorry for the confusion! Was a great challenge tho as someone who using this to practice alongisde a python course I've been taking on Udemy
Rust translation.
Thanks, approved.
Thank you! :-)
I think the time complexity of O(n) in not optimal for large strings and we can find wrong character with the time complexity of O(logn)
Not a kata suggestion ~~
Finally solved it. I always experience good feelings after solving one of your's kata which I wasn't be able to tackle at first try.
Many thanks.
A little typo : and you task -> and your task
Awesome kata, thanks!!! :)
Many thanks!
In Scala:
assert(solve(null) == "not possible")
Really? Nulls shouldn't usually be a valid input, definitely shouldn't be when the behaviour isn't obvious, and in a functional language they just must not be.What should it be?
Ideally this test shouldn't exist at all. There're no tests with
None
in Python andnull
in JS, it doesn't make sense. In general case there'sOption
which is a standard funcional option/maybe.Ok. Just approved this today. Not familiar with Scala, but will look into it.
Scala deleted. Issue resolved.
It's surely resolved. Looks like an overkill though, considering it was a good translation otherwise...
I have very little tolerance for inaccurate translations. If it's in a language I don't understand, that tolerance is zero.
This comment has been hidden.
Many thanks B4B. I'm on the road and will sort this out tonight.
I've made all the changes. On your edge cases above, the "not possible" should be "remove one" if we remove 'c'. I've added a few more tests as well. Most important, fixed tests appear at the top as you suggested (which knocked out the cheat solution) and random tets are in a function. I think all issues are resolved, but you are
1 dan
, so I will wait for your approval :-).I think the name is perfect, since it's all about finding out if removing a
single character
can give you apalindrome
. Please don't fight me on this.Many thanks B4B!