8 kyu
They say that only the name is long enough to attract attention. They also said that only a simple Kata will have someone to solve it. This is a sadly story #1: Are they opposite?
3,993 of 11,171myjinxin2015
Loading description...
Puzzles
Games
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.
This comment has been hidden.
Haskell: There are no tests where the case-alternation matches but the letters are different.
Hello!! im having a little fun here..
It seems the random tests generates values and expect them to be the opposite thing. Also i've submitted a solution that's not right because of this problem. Here is some examples of the strange test: // s1="QWDQPHcWyZ" s2="qwdqphCwYz"; expected: 'false', instead got: 'true'
why does this happen? hoping to get the question has a good answer😝
IMO, you are reading the logs wrong. Read this for more info on debugging
Also, seems like you've solved it, closing!
This comment has been hidden.
Your code is wrong, not a kata issue.
Scala translation
Approved
C translation has horrible error reporting :
The expression (submission) == (solution(rs1, rs2)) is false.
Please show input strings and results."if both strings are empty then you should return false/False." So, what does "false/False" mean? Is it a string? Why does one 'false' start with a small letter and the other with a capital letter? This condition is confusing
False
is for Python,false
for almost any other language. There are no quotes, so, no, it's not a string. Also, there is a note in the description:Thanks for the quick prompt.
NASM translation
Lmfaoooooooooooooooooooooo!!! There is NO way this is 8kata!!! BS. explain how this is the easiest level lololol. joke.
Description should be language-agnostic
Done
C++ translation
Please, review.
Approved
You're right. The name did attract my attention :)
Please double check your random tests. Thank you.
Can you please tell me the programming language and the problem with them?
This comment has been hidden.
What's wrong with this? The letter
M
at index has same case in both of the string, hence the result should be false.if my solution was accepted, then the tests are not written correctly?
very poorly written kata
Could you elaborate why?
Regarding C
This is a very minor issue, but after the language version updated the tests generate a warning
Warnings cleared, thanks.
Logically it would make more sense to set isOposite "" "" = True, as it is an empty condition, which is always fulfilled. I also suggest you to include testing cases, where the two strings do not only differ by upper or lower case, but also by letter.
Agree
Python testing suite (maybe other languages too) isn't right, solutions like this one shouldn't pass.
This comment has been hidden.
When the condition isn't met, it returns
False
. The problem is there should be tests cases where the first letter is different letter case and the expected value isFalse
.I got everything right except for the last sample test is_opposite("" , "") keeps giving a NONE SHOULD BE FALSE.
Not a kata issue, your function is returning
None
or not returning and that's the default return value for Python. You can see in the kata description thatFalse
is the expected value for those input values.There is a problem with the random test generator: s1="QWDQPHcWyZ" s2="qwdqphCwYz"; expected: 'false', instead got: 'true'
s1="HMLLqNdI" s2="hmllQnDi" Expected: 'false', instead got: 'true'
s1="wPtGzFsNjxFCm" s2="WpTgZfSnJXfcM" Expected: 'false', instead got: 'true'
As far as I can tell, I see no error in javascript tests (please, mention the language next time). The log appears above the test result, could it be you're confusing the input of one test with the expected result of a different one?
I just double checked and I do not think I am making that mistake. Just to be safe, the log appears above the outcome, correct?
Hi, I want to know: what language you are using?
JavaScript
PureScript Translation Kumited - please accept :D
Approved. Sorry for late.
This comment has been hidden.
C: edge cases like
is_opposite("A", "aa")
are never generated: https://www.codewars.com/kata/reviews/5c3b108a96ba1a0001105126/groups/5c3b1b7b14ef8c0001c4b1dehere's the fork of the new code:
https://www.codewars.com/kumite/5c3a43445ca4de6d08d77f88?sel=5c3dd3003db0fa3cc0d87a22
Approved.
C translation kumited
please scrutinize for approval
domo!
Approved. Cheers ;-)
Ah. issue. Please fix it. ;-)
this has been available for a week, but Unnamed hasn't noticed it or has been busy elsewhere.
he helped me with the corrections and gave me the go ahead for a fork but I don't want to self approve it
https://www.codewars.com/kumite/5c3a43445ca4de6d08d77f88?sel=5c3dd3003db0fa3cc0d87a22
Sorry for late. I've not seen the comment. Now it's approved.
great, thanks!
Random tests that should have passed, failed. They were asserting the wrong expectation at a rate of roughly 4/106. Ex: "Ab", "aB" expected to return false - it should actually (and did) return true but failed the test due to wrong expectation.
This comment has been hidden.
"My code doesn't pass the tests" is not an issue, but a
question
;-)Strings are immutable in JS. Have you been using languages like C++ in the past? ;-)
This comment has been hidden.
"abc" and "abc"
"Abc" and "aBc"
And, your
if(...){....
missing a}
C# translation Kumited, please review and approve if it looks good.
This comment has been hidden.
The test code can not be modified any more, because it's locked by CW.
Is there a forum for this site where you can get help with Kata's? I've been stuck on this one for a while and haven't been able to get the help I need to try and complete it. Thanks.
https://gitter.im/Codewars/codewars.com
Despite the fact that in almost 75% of the cases my solution didn't pass I managed to got it completed :)) I think you should include in the must pass tests a case when the string are totally different like this s1="JKfehAidjqZM" s2="iBPcXTszvkXnk"
Thanks for this Kata, keep up with the good job
Thanks for your suggestion ;-) This kata was locked by CW. because there are more than 500 guys solved it.
This comment has been hidden.
Surely,("aBcd", "eFgh") should return
false
. But I don't know which language will returntrue
. I guess that you are saying aboutpython
, am I right? I checked it inpython, ruby and javascript
versions, try to add this("aBcd", "eFgh") to the testcase, they all returnedfalse
.This comment has been hidden.
Thanks ;-) I added this to the description:
Haskell translation kumited. Please review and approve. Regards, suic
Wow, Haskell, thanks ;-)
@suic, thanks for Haskell translation :)
I don't think current reference implementation matches the original (@myjinxin2015's JavaScript). Example:
JavaScript version does test strings with different lengths during random tests. But they are more obvious pairs like
"VgbA", "BLWoqnUt"
. I think the pair"aBcde", "AbCD"
is a good test case to add to JavaScript as well, but maybe too late.JS version add a basic test
Test.assertSimilar(isOpposite("aBcde","AbCD") , false);
And add some random tests like this ;-)@kazk and @myjixin2015
Let me explain :) My reading of this is maybe to strict:
All the letters of the two strings are the same
i.e. the two strings contain the same letters. Fors1="aBcde"
,s2="AbCD"
it's true thats1
contains all the letters ofs2
if you make a case-insesitive comparison. However, this isn't true vice versa. Strictly speaking the test case doesn't correspond with the qouted sentence.However, the test cases in JS say something else. I'll fix my translation. Hovewer, I suggest adding a note to the description about different string length. Just to make it explicit. :)
Regards,
suic
@suic,
This is the definition of oppsite, so the function
isOpposite
must returnfalse
if this is not satisfied.isOpposite("aBcde", "AbCD")
isfalse
because all letters of the two strings are not the same. That is,"abcde" != "abcd"
. I agree that it's confusing, it feels similar to those double negatives like "not case insensitive" which gives me a headache :(If I misunderstood you, can you give me some examples of test cases not corresponding to the description?
edit: reworded
@kazk:
I fixed this in the meantime. :) You're correct I misread that sentence (I realized this after I'd reread your comment 3(!) times :)). English is not my friend and it never will be :D And also: followed the Python translation which doesn't contain that test.
Thanks,
suic
P. S.: I'm not sure about your mother tongue but in mine we normally use double negatives for single negatives (which is common in Slavic languages too :))
Hey,
i think there needs to be at least one more test case (in my case JavaScript):
Test.assertSimilar(isOpposite(" ","@") , false);
Those are not "opposites" in the sense of the description but my solution (and others) return true in this case. The description states that we have two "strings" but the definition of opposite states that only letters need to be of different case. So i think everything but letters should stay the same.
This, or the description should state that only letters will be in the string.
Just came to my mind after testing a bit.
Thanks for your suggestion, perhaps I should add
you can assume the string only contains letters or it's a empty string
to my description ;-)Added. I think a 8kyu difficulty Kata does not require too complicated input validation.
cool :-)
Hi. What are the test cases for Submit please? I keep failing the last one. It looks as if it's the same test case as Test but it can't be as I pass Test fine.
@myjinxin2015
,Python PEP8 - Function Names
Suggestion:
def isOpposite(s1, s2):
should bedef is_opposite(s1, s2):
fixed, thanks ;-)
Awesome, thanks!
@myjinxin2015
,I just went to re-submit my solution and the example tests and test cases are fixed but I noticed the sample solution code still has the function name
isOpposite
.OK, FIX in 1 minute
Done ;-)
Looks good! I think that might have been a world record, you're fast.
I'm going to apply for the Guinness world record ;-)
Ruby: needs the following test cases:
Looks like you added them. Thanks.
Ruby: Needs random test cases.
This is a transltion, please wait the translator to fix it ;-)
Oh,there is another ruby translation create, it looks contains random testcase, how can I replace it?
Ok, I copy and paste the code. Now it fixed. please test ;-)
That works. Thanks!
Logically, shouldn't the return value for two empty strings be true instead of false?
Logically, I think that two same string("" and "") are not the opposite string ;-)
Well, all the characters are opposite .. :]
0 and 0 are additive inverses. 1 and 1 are multiplicative inverses.
Ruby translation submitted.
approved ;-) Thanks for your work~~
Can you add some random testcases?
CoffeeScript translation Kumited! Please Accept :d
The name of the Kata was hilarious, loved it <3 ;)
Yes =) Nice name xD
Nice and easy kata! Good job again, myjinxin2015 =)
Is it "best practice" to mark each own solution as "best practice" (here it's only one example...), altough it's visible that it isn't...;-)? It brings no extra points (i think?) and it "hides" other and better solutions...