7 kyu
Common Substrings
176 of 2,166Shivo
Loading description...
Strings
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.
Java:
camelCase
, notPascalCase
Refer here on how to enable backward compatability to not invalidate all solutions
Im getting this error message when I attempt with Javascript:
ReferenceError: SubstringTest is not defined at /home/codewarrior/index.js:24:63 at /home/codewarrior/index.js:70:5 at Object.handleError
I dont think there is anything I can change prevent the error. I dont have access to index.js. My solution passes the test cases and works in my IDE.
I've recently made some changes to this kata.
Try the following steps to see if your issue is resolved.
Copy your solution to somewhere safe
Press the
Reset
button in the trainer (located at the bottom)Paste your solution back in the solution window & press the
Attempt
/Test
button.Thanks! My solution works!
I came across such a problem on leetcode. And his level was definitely higher than easy
This is a level 7?
Shorter description:
Given two strings, determine if there is a common substring longer than one letter.
Return true if found, false if not. Case-insensitive.
C translation (author gone)
JS:
Node 18. (
mocha
+chai
) should be enabledfunction name should use
camelCase
Enabled Node v18 & camelCased function name (with backward compactibility) in this fork
Very poor description. What is "common"?
for example take tese 2 words "some" and "home" ------> "ome" is common among both, it is clearly present in the question, You missed it!
Thanks
Ruby 3.0 should be enabled.
Enabled in this fork
Python 3 should be enabled.
This comment has been hidden.
Your code only checks for the first occurence of a character. So, it will fail for cases like
str1 = Codewars is sweet!, str2 = is
because it will compare the index ofs
which is at position7
instead of10
This kata is not easy! I've lost 60 minutes but still can't resolve it! Actually, I finished all test case except a test case with very long string.
Frustrated! :(
This comment has been hidden.
Please provide the test criteria for randTests, ReversetOfExample, and MediumString. I'm getting the follwoing but don't know how to further troubleshoot this.
randTests(KataTest) expected: but was:
ReverseOfExample(KataTest) expected: but was:
MediumString(KataTest) expected: but was:
I do not have the ability to edit Java problems, and even if I did, it is a bug in the Java compiler that those aren't showing up. It will likely be fixed in the future. If you go to any other kata in java expecting a boolean, you will get the same issue unfortunately.
Hello, I am also having an issue with the randtest. I initially posted too much of my code, but I am not sure how to resolve that issue. Initially, I thought it involved non-alpahabetic characters, but I still received the error message. Can anyone offer suggestions on what types of things are being tested in the randtest?
Few questions:
Feel free to post your code if you would like. Just place a ```` before and after the code. This will make it so that your code is in the code format. Also, if you post your code be sure to click on the spoiler checkbox.
This comment has been hidden.
Hi! Please change name of the method to camelCase style (in Java kata). It hurts my eyes.
Hey! I would if I could, but codewars currently has a bug that makes it impossible to edit Java katas. When it becomes possible to modify, I will change it. I promise :p
Thanks!
Reraised as an issue :-)
What does the randTest test? I have 10 of 11 test correct except this test. Has this "rand" something to do with the edge of the String. I do not test for single letters but after the description I dont need to. Certainly I miss to test certain strings but by the name of the test I do not get a hint what I miss.
randTest tests your answer against random input strings. What programming language are you using? Feel free to post your answer here under a spoiler tag, and I'll take a look at it.
clojure.set wasn't working for me in this kata. I had a exception when tried to require it
Python, Basic Tests: "False should equal True" for Test.assert_equals(substring_test("supercalifragilisticexpialidocious","SoundOfItIsAtrocious"), True) str2 has "n" and str1 has not. So should be False. Please fix.
There is "ocious" and some other common substrings, so it works how it should.
As unnamed said, your job is to tell me if there is a substring that appears in both strings. In this case, "ocious" appears in both strings, so your function/method should return true. I'm marking this issue as resolved. If you have any other questions, feel free to ask.
Thank you for explanation! Next time I will be more attentive.
No problem :) thanks for the feedback!
The random tests in Haskell are overly verbose. Instead, use
Modified, thanks again!
Haskell translation kumited.
Awesome! Thanks a ton. That's all of the languages for this one.
This comment has been hidden.
Removed, thanks!
Everything should now have random test cases.
Minor issue with the Java version:
should be:
For future Java katas:
Method name should start with a lowercase letter
SubstringTest(...) -> substringTest(...)
to follow the Java style guidelines but that would invalidate all current solutions, so just fixing thestring -> String
will do.Random tests:
Some random tests would be nice, as at least one solution just checks if a specified test value is present and returns the wanted result....
Cheers
Thanks for the tips, I'll work on updating this to put it in the correct format and to get it working properly with random tests. I'll let you know when it is finished. Thanks for the feedback :)
Alright, I have fixed everything except for the naming scheme. I would have fixed that too, but Java on codewars is tough to update without locking up the publishing process. I have added random test cases to java as well. I'm going to go ahead and add random cases for everything else as well. I will go ahead and mark this as resolved, but if you have any other issues let me know with another issue.
Looks good. :) Thank you for fixing everything so fast.
Don't worry to much about the naming scheme. Switching between C# and Java can sometimes get a bit confusing. I'm having the same problem just the other way around... ;)
The funny thing is that I started in Java and moved to C#, and I had the same problem as you. Now it has completely flipped and I'm having trouble going back to java. :p Thanks again for the feedback I'll keep everything you said in mind on my next Kata.
Clojure translation kumited.
"In the Python random tests for:
substring_test('sNFiT3qmsnQwAMeXzzP','3UqW')
I returned True (because ofQw
andqW
) but the test failed; it was said that I should have returnedFalse
. Maybe you should have a look?"I think I maybe found an error in the Python solution. Try
Test.assert_equals(substring_test("Codewars is sweet!", "is"), True)
. The solution and reference solution returnFalse
. Maybe look atxrange(0,len(str2)-2)
. Did you notice Giacomo?Alright, so I did find a small issue in the random test case where Giacomo was raferencing the wrong function in his recursion. You are correct though, there is something wrong with the solution itself. I'll get Giacomo to look at it.
Alright, it should be fixed now (fingers crossed). Let me know if it is working for you.
Should be fixed now, thanks for the notification and g964 was right :)
Alright, I'm marking it as resolved :) Thanks!
Coffeescript translation kumited.
In the Python random tests for:
substring_test('sNFiT3qmsnQwAMeXzzP','3UqW')
I returned True (because ofQw
andqW
) but the test failed; it was said that I should have returnedFalse
. Maybe you should have a look?Alright, I'm marking an issue for this until I have time to look it over.
Translated, also with sweet one-liners with an eye to performances ;)
Also: this kata is very close to being approved, so when you see it with a green bar, feel free to post below here to ask me for it to be fully greenlit :)
Thanks! I have approved them.
Hey man, take a look at the issue in this one. It seems your solution fails for
Test.assert_equals(substring_test("Codewars is sweet!", "is"), True)
. I'm going to look into it as well, but if you read this before I finish, I will just let you handle it.I went ahead and updated it. I left your one liner in there commented out. I figured you may want to play around with it a little bit. If you get it working, feel free to use that instead of the solution I used.