7 kyu
Isograms
2,526 of 262,532chunjef
Loading description...
Strings
Fundamentals
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.
не мог решить относительно долгое время. Мучался и не мог понять в чем дело. Оказалось, что забыл игнорирование регистра(
JS fork
ok
why cant i use 'for' to compelete the issue?
You can use a
for
loop. Your current solution use one but never updatesstatus
. This is why you are always returningtrue
.I'm not native English speaker and new for the Codewars. I just saw now that "ignore letter case" is correct for ignoring upper case letters. It's a synonim indeed. Sorry for my confusion. Would be better remove the comment. I put ISSUE because didn't find a label like "suggestion". Thanks guys for alerting me.
Would be something like "ignore case sensitivity" instead of "ignore letter case"
I don't think this is an issue, "ignore letter case" means the same as "case insensitive", I don't see how this is an improvement.
Not a kata issue, a suggestion at best.
"case (in)sensitivity" is a pretty standard term, I'd get used to it
The instructions state that the function should be case INSENSITIVE, but one of the tests requires case sensitivity (i.e.: "MoOse === moose" // false;).
I would appreciate some explanation from you why you consider my answers wrong, and what is the error in tests you are complaining about, because I think I am missing something:
moose
is not an isogram, because the lettero
occurs twice.mOose
is not an isogram, because the lettero
occurs twice, with differend case (lowercase and uppercase).The occurrence of letters should be done in a case-insensitive way, i.e. both lowercase letters and uppercase letters contribute to the count of occurrences. And this is how it works in JavaScript translation. So, what exactly you think is wrong?
Please read the definition of case insensitive here: https://en.wikipedia.org/wiki/Case_sensitivity
In case-insensitive, uppercase and lowercase letters are the same, and that's what the test asks.
Please reread what I wrote and re-check your tests. As many other users have pointed out, that test fails for them, as well. Case insensitization would mean that the case wouod be ignored, so MoOse and moose would be treated the same way. That isn't happening as it should be; it's not working as intended. Check your work.
The tests expects false, I don't know what you're complaining about, the test is fine, you're wrong.
That is the test, if it was case-sensitive as you claim, it would expect
true
becauseo
andO
would be considered different letters, but it isn't.Test for "moose" expects
false
. Test for "moOse" expectsfalse
. Relevant assertions in tests are:Doesn't this mean they both behave the same way? What is different about them?
When I click attempt this test (UpperCaseAlphabetPlusOneChar) returns an error saying the expected result was False but it returned True, however when I try it in VS it returns false
This comment has been hidden.
hi, I've put the spoiler tag on your comment because anyone can see it, whether or not they have passed the kata. So: do not ever post code in this way
my code keeps outputting runtime error even though when i do it on the ide, it runs instantaneously.?
Yeah, maybe. We don't know.
Seeing your code would help tho. Or at least knowing the language.
This comment has been hidden.
Your solution contains UB when called with an empty string as input. Did you test your solution in your IDE with an empty string
""
?This comment has been hidden.
Please use appropriate markdown formatting and flag your comment as a spoiler when posting code. See https://docs.codewars.com/training/troubleshooting#post-discourse.
Reread the description, your solution doesn't meet one of the requirements.
Can we really ignore case in this kata. Upper case character and lowercase characters are different unicode characters. Why does he say ignore the case?
Because this is the specification. In this problem, words like
"Anita"
or"Shrimps"
are not isograms.The same or different "unicode characters" is not really relevant. "unicode characters" is a technical thing, while "letter" is more of a language concept. Bringing technical concepts into the domain of the problem is a mistake.
This comment has been hidden.
"ignore letter case" means that when you compare two letters for equality, it does not matter what case they are. For example,
S
ands
should be treated as the same.This comment has been hidden.
No. Actually by using toLowerCase(), you are doing alright. You might as well use toUpperCase.
There are absolutely ways to ignore casing here. Unfortunately, one of the tests written requires case sensitivity, so your function might be perfectly correct and still fail to clear this kata.
Look at my code, pls
This comment has been hidden.
Ignore letter case means a capital letter is the same as its lowercase version. How you handle that, it's up to you. Not a kata issue.
This comment has been hidden.
There is nothing to fix (well, I restored a sample test in the description, someone messed it up, but that was a sample test too, so you should have seen it), neither in the description nor the tests, and I already explained what that means, bye.
This comment has been deleted.
You need to take a deeper look into your code. Right now it will always return true, because you're storing a character at some index, and then checking from beginning again so you reach the same index again, and obviously it will return true when you compare the 2.
Make use of
console.log
to debug your code, avoid global variables, and take a closer look at the description. "aba" should return false.This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Your code always returns value after first iteration. You can easily see that if you add one print().
This comment has been hidden.
Your code is wrong. Not a kata issue.
Why it doesnot has Arrays.stream()?
You need to import the libraries yourself.
This comment has been hidden.
That's because you have a subtle error in your logic: your code will return in the first iteration of the loop. Your code translates to something similar to: if this, return this, else return that (first iteration). By adjusting your overall structure (which in this case, is just modifying number of tabs/spaces for some line(s)), your code will pass.
To OP: Please mark your post as having spoiler content next time.
This comment has been hidden.
This comment has been hidden.
It never is.
This comment has been hidden.
The issue lies with your if-check. Can't get into more detail otherwise you wouldn't be able to see this comment if it's marked as a spoiler. But, essentially, you're not applying the case-insensitivity on the original string. You're doing it on the wrong parts. Think about how and why your solution would mess up with strings containing uppercase chars like
HOOP
orhOOp
. Are you searching for a version of that char that doesn't exist? That's about as many hints I can give without spoiling.Your code not working is not a kata issue. Please check https://docs.codewars.com/training/troubleshooting for some tips.
If you want to post code, use code formatting: https://docs.codewars.com/references/markdown/#displaying-code
Forked the C++ translation to introduce random tests and other UX changes.
Forked and approved
In another one IDE work good, but not here
You're not returning anything, that's why. Check out https://docs.codewars.com/training/training-example
I get this error: STDERR: Traceback (most recent call last): File "/workspace/default/tests.py", line 2, in from solution import is_isogram ImportError: cannot import name 'is_isogram' from 'solution' (/workspace/default/solution.py)
The import 'is_isogram' belongs to the test cases, not my code! Any thoughts?
it's trying to import it from your code since that's what you're supposed to define. that's the task. define that thing. it's failing since you haven't defined it.
Change
isIsogram
tois_isogram
in your code.This comment has been hidden.
not a kata issue. your code fails for e.g. "moOse"
tried the exact code both here and on a different IDE. it fails the caps test here but works outside.
Then you can use the test cases here to update your IDE.
This comment has been hidden.
You should return the result instead of printing it, read this
This comment has been hidden.
Try to print the input using
console.log
.dfdf
Great Kata, to mess your brain with. Always remeber to use the upper or lower function so we could keep all the elements in a single format and check on with the duplicate values :D
your comment help me alot
Swift translation
This comment has been hidden.
Check what your code does here
This comment has been hidden.
Похоже, что твой код считает заглавные и строчные буквы как разные, и
Set
получается больше, чем надо.Попробуй использовать
str.toLowerCase()
шя попробуйу и спасибо за совет
tried my code on a different IDE, it works fine. But when I attempt here, it gives me a different result even though it's the exact same code and the exact same test.
In what language?
From description: "Ignore letter case."
Your solution returns incorrect answer for input
"moOse"
. It sohuld returnfalse
, but returnstrue
.It's a bug in your solution, not a kata issue.
in c++. the test is "DermatoglyphicsmooseisIsogramabamoOse" expected false. on the site my code returns true when on my IDE it gives false.
There is no test with input
"DermatoglyphicsmooseisIsogramabamoOse"
. You most probably read (or write) something wrong.Once again, what does your solution return locally in your IDE for input
"moOse"
?"DermatoglyphicsmooseisIsogramabamoOse" is the input of several tests together, add a new line after printing the input.
This comment has been hidden.
Hi,
there is already a page full of solutions, no need to post yours in the discourse page. Moreover, do not post solutions/critical inforamtions about the solution without a spoiler flag, thx.
Cheers
Hey, we got a section known as the solutions for this. Dont post it over here. also we could finish this up within 3-4 lines and reduce the complexity :D cheers!!!!!
same chars may not be adjacent: expected true to equal false What do you mean by that can the creater of the question please specify what does that mean
Print the input and you'll see it.
This comment has been hidden.
Not a kata issue, don't use global vars, they keep their value between tests, as written in the Troubleshooting. Use
Question
next time.This comment has been hidden.
Your solution fails to do this
This comment has been hidden.
You don't need to create static
Main
method and log the result there, since that's not how codewars run your solution. The tests directly runs theIsIsogram
method. So, you just need to do it all inIsIsogram
instead.Sorry, I don't think I understand the instructions well because why should TRUE equal FALSE in the test below? "Testing for fpMeFV True should equal False" Yet f appears twice, just in different cases. I'm failing this kind of test and I think it may be because I haven't understood the instructions. Can anyone please explain.
If it has two
f
s, then it's not an isogram.This comment has been hidden.
Your code is wrong, with the second loop if/else you're only analyzing the first char. Please mark your post as having spoiler content next time.
All cases pass except the "thumbscrewjapingly" one here. But the same code runs fine when I compile and test in Visual Studio.
Your current code works fine.
This comment has been hidden.
This comment has been hidden.
i passed the tests but when i attempt it gives an error
Sounds like there is a problem with your code still then.
there's usually way more tests in the attempt than the ones you can see in the test cases which run when you click test.
ur right my bad
np glad you got it sorted.
This comment has been hidden.
That's a hint, not a kata suggestion. Suggestions for the kata are changes on the description, adding some tests, a new translation, etc.
I tried my code on codeblock and it fine but when i tried my code in this site it giving me error.
OP passed the kata, closing!
Hello guys, I just got into python and I was wondering how to understand the questions and give sensible answers or solutions. The problems seem easy enough but I don't know where to start from. Any help is appreciated.
Hey @Ebenezer D. and welcome to Codewars!
Are you confused by the Codewars interface/environment and how to submit your solutions? There is this document here:
https://docs.codewars.com/getting-started/solving-kata/
which may be useful; alternatively you can join the Codewars discord (link in sidebar on the left) - there is a dedicated #beginners channel where you can get help starting out with the site.
But basically, you can pretend that you are working on your local PC - try to write a function that solves the given kata task, test it with a few different inputs to see if it works as you'd expect. Then you just copy paste that into Codewars and that's roughly all you have to do - Codewars will test your solution usings the test data that you can see in the bottom right of the screen, in the section "Sample Tests".
This comment has been hidden.
Your code doesn't see different case letters as the same letter. There are some other problems there, but I'll let you to figure them out.
This comment has been hidden.
If I compile my code with gcc on another online compiler and on gcc on my mac it works, and returns true with the cases that here returns false. I don't know if it's my mistake or not, I am still a beginner, but worth reporting.
This comment has been hidden.
This comment has been hidden.
OP solved it, closing
Really Confused on what this STDRR error means and why I'm getting this
File "/workspace/default/tests.py", line 4 "Dermatoglyphics" --> true "aba" --> false ^^ SyntaxError: invalid syntax
looking at your solution, it seems that you are passing all the tests xD
if you wish, could you send this error message with proper formatting as its pretty hard to read where the invalid syntax is
This comment has been hidden.
Thanks, bro, I puzzled over what was wrong, it turns out the same case as you, now I have a clue at least
"Dermatoglyphics" --> true "aba" --> false "moOse" --> false (ignore letter case)
I think it's better to split this string with more space (or ;) or to write it as three lines.
edit: you already have examples below, so this string should be removed.
Fixed
F# translation using new F# setup for tests.
Approved by someone
This comment has been hidden.
Please mark your post as having spoiler content next time, your code only analyzes the first letter of the string, it either returns True or False based on it.
My apologies - and thank you!
Inconsistency in input-casing generation
Python && ruby: input will only generate lowercase letters
JS && CS: Very low probability of generating lowercase letters
Random tests should be modified to randomly select lower + uppercase character from a string!
i've uploaded a fork to address this issue in python
python addressed
addressed in JS
this testcase('same chars') returns True in my local return False can some on help
Not a kata issue, and there is no test with that input. Print the input to help you debug your code.
This comment has been hidden.
Fixed.
One of random test, which wasn't passed - "ekdvikbp: expected true to equal false". How can be expected true, if 'k' is twice here?
Which language?
TypeScript
Hi, I don't use TypeScript but often this format of error message means "expected
your answer
to equaltrue answer
"In other words - again I'm not TypeScript user so I'm not 100% sure on the tests - it might be that your code is currently returning
true
.To debug quickly: Check locally in your IDE for this particular input string, or include a "print" statement at the end of your code
print_to_console : result
(however you do this in your language) which will allow you to see what you are returning.It's like Benjamin said, add this test to sample tests:
You can see there are two
z
s there, the right answer isfalse
, but your code returnstrue
instead.Test cases are running fine but showing error when attempted: Expected: false, Actual: true
Read this: https://docs.codewars.com/training/troubleshooting
Error messages in random tests in Ruby show this:
fixed
This comment has been hidden.
Fixed (you may have to click
reset
in the trainer to get the updated tests; save your code locally if needed).D translation
Ok. Tried in different ways. "Cannot resolve Arrays.sort(arr)". Am I dumb?
Is this Java? If yes, try to have this " import java.util.Arrays; " into your solution.
This comment has been hidden.
I ran my tests and all are true, but when pressing the attempt button, some tests don't work, so I ran them in another IDE and it worked, so what's the problem, what should I do?
Not a kata issue, read this: https://docs.codewars.com/training/troubleshooting/#your-solution-seems-to-work-or-is-close-to-working-but-still-fails-tests
Scala translation
Approved!
Why I can not using a set?
Hi. Please say which language you are using when it can be relevant. I assume, after seeing your profile, that you must be using c++. To use
std::set
you must include the corresponding header. See the documentation: https://en.cppreference.com/w/cpp/container/setThis comment has been hidden.
OP solved it, closing
same chars may not be adjacent Failed asserting that true matches expected false.
Beginner in PHP, can anyone help rectify this error?
Print the input, see what the error means. This test could match that error message:
This comment has been hidden.
Ok.
This comment has been hidden.
Hi. Questions in Discourse are expected to be concrete questions about the kata itself. The solutions must be posted on the solution page. You can post a comment to your solution, or to other solutions and ask questions there. If you want a general support about programming in some language, you may try to visit Codewars's Discord kata on the channel dedicated to Python (link in the left panel). A good way to learn is to examine other people's solution. Once you solved a kata, feel free to copy a solution and make modifications or trials. The best way to enhance is to practice.
This comment has been hidden.
Your solution passess all tests, so not a kata issue!
This comment has been hidden.
This comment has been hidden.
I think I can do string = string.lower() first.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
That's a problem with your code, not a kata issue, why do you have this?
Please read this: https://docs.codewars.com/training/troubleshooting
This comment has been hidden.
Print the result of
len({string})
for yourself and see what you get) And, by the way, you don't need ternary operator there. You could just return comparison resultthanks
This comment has been hidden.
... but what exactly do you suggest?
Please, don't post solutions in Discourse.
This comment has been hidden.
Don't post solutions in Discourse, there is a Solutions section for that.
This comment has been hidden.
Please don't post spoilers like that in Discourse.
oh i see. got it. Will take note of this. I thought having a spoiler flag will be a indication of the comment indication solution.
en JS---no entiendo porque el test "aba" debe devolver false ? en el enunciado no indica que eso.
aba has two a.
This comment has been hidden.
Your code only checks the first letter of the string like that, please, next time mark your post as having spoiler content and use markdown formatting, read this: https://docs.codewars.com/training/troubleshooting/
This comment has been hidden.
COBOL translation.
approved
C fixed tests include twice the same input "moOse".
fixed
'thumbscrewjapingly' is an isogram but should return false , what i am missing ??
No, it should return true. You may be failing another test after it.
i mean it should be true, but in the testing the answer is false. Its the only case that i got wrong
The test with that input in Python expects
True
, check your code. If you're printing the input, it appears above the test result.This comment has been hidden.
Not a kata issue, you're not returning anything.
This comment has been hidden.
This comment has been hidden.
in step 4, in the second for loop k should equal to 0 and add a condition in the if statement when i != k to avoid comparing the same letter.
OP solved it, closing
This comment has been hidden.
Have a look there: https://docs.codewars.com/training/troubleshooting.
Implement a function that determines whether a string that contains only letters is an isogram.
This means the input should always be a string formed of letters. However, at least in C, we receive things like "a_string", which doesn't match.
Same thing in Julia (we can have numbers and other characters). Apparently not in Python and NASM. Other languages to be checked.
fixed for C
Fixed Julia, checked all languages as well, closing
This comment has been hidden.
In line number 6, You should return true, If it ain't, it will print false for isogram words also
This comment has been hidden.
Because in the second For loop you compare all characters with the current character at index i, so also the character with itself. And of course, when you compare something to itself, it's the same.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
I wrote solution and test in VS IDE and their works perfectly. When i test it here it shows everything correct but when i make attempt there error. Who knows the cause of the problem? The Error: In file included from main.cpp:6: ./solution.cpp:5:23: warning: comparison of integers of different signs: 'int' and 'std::__cxx11::basic_string<char, std::char_traits, std::allocator >::size_type' (aka 'unsigned long') [-Wsign-compare]
I don't see any error, just a warning. It's also referring to your code, soultion.cpp, so it's not an
ISSUE
with the kata, is it? The warning states what the problem is. So. What exactly are you asking? :xThanks for respon. I found the cause.
Closing then.
// i use array like this var arr= [1,2,3]
// but what is this thing called..? var [c1, c2, c3] = [1,2,3]
// i am beginner in js
Read this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
It is simple you are putting value at 0 of [1,2,3] to c1 which is a variable and so on like that c2, c3 stores value for index 1, 2.
This comment has been hidden.
I was able to pass the tests from copy pasting your code so I can't speak to what the difference is, but I noticed you have a spurious global 'x' when you pass index + 1 to arrString.includes(). It works because the "x = index + 1" returns the new value of x, so its equiveleant to just "index + 1"
That´s strange... Ok, copy and pased the code from here in the forum and it worked?!
Thanks for the pointer regarding my x var!
This comment has been hidden.
Please read this paragraph: https://docs.codewars.com/training/troubleshooting#post-discourse , especially the bullet point about not posting solutions in kata discourse.
This kata is asking to "Implement a function that determines whether a string that contains only letters is an isogram." Most solutions don't check for digits. And there are no test cases for that either. What am I missing?
You misread the description. We're given a string that contains only letters, there is no need to check, we must only check it does not contain duplicates.
Thanks for the response! It just feels like it is a bit too open to interpretation.
Well, it could be reworded with less density, but actually it is accurate (or it would have been something like check whether the string contains only letters and is an isogram). Atention to detail is important in programming ;)
This comment has been hidden.
This comment has been hidden.
There's no need to compare with the empty string, since the outer loop will never be entered when str.length is 0 (becase 0 < 0 evaluates to false, the whole loop is skipped)
The issue with this code is you're returning 'true' before the outer loop has a chance to iterate, so you never compare the second letter with the rest of the string.
Move 'return true' down one line so it's the last thing that happens in the function and you will pass the tests without your str === ''
Thanks a lot! I get it :)
This comment has been hidden.
There is nothing to fix, click reset or make sure your code is like this:
It seems you're missing the
export
keyword or something like that.This comment has been hidden.
Please don't post solutions in Discourse.
This comment has been hidden.
This comment has been hidden.
Don't forget spoiler flag. Your code is basically:
This code means that it will only check 1 character and return instantly. At least one of these returns should be outside loops.
thank you very much for solving my doubt. now i get it why i was having this error.
An important thing to note here is that the string must be cleaned prior to the check by using the builtin .lower() method.
attempt resulted to: Test Crashed Caught unexpected signal: SIGSEGV (11). Invalid memory access. what is the meaning of this error? I'm using C
Segementation Fault, post your code here so that we can help you out (if not fixed yet)
I've made an attempt to translate to NASM.
NASM Translation
Approved
This comment has been hidden.
print
returnsNone
, please read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution remove all your prints and return the result instead. Not a kata issue, use question label next time.Yes i had a look to the FAQ and i saw i was returning prints....Thanks.
Crystal translation
Thanks :)
This comment has been hidden.
That's because you need to
return
instead ofprint
the result.This comment has been hidden.
This comment has been hidden.
hey! don't post solutions here! especially without the spoiler flag.
No random tests in
added in C
forked the C++ translation
Forked and approved C++
This comment has been hidden.
Please don't post solutions in Discourse.
my code: https://github.com/arataca89/Cplusplus/blob/main/isogram.cpp
in CodeWars not work, but here work fine.
Same problem..
Why my solution it not beeing stored? It passes all the test cases, it shows the correct message after submision but "my solutions" keeps saying there isn't a solution yet. I've tried twice
This comment has been hidden.
the fact that you post this as an issue instead of a question, for one... ;p
for two: you're not managing the case thing properly
This comment has been hidden.
I don't know what you did, but the test about "isIsogram" is expecting false, not true. If you don't get why, read the description again.
in any case, not an issue, a question => cliosing.
Hey, I am sort of newbie to Python and Codewars. I am pretty much confused how to go throught this platfrom. What is Test Case? Is this sort of solution or some template to solve it?
A test case is usually a call to your function with a particular value in it that you do not know. This acts as an effective way to test your work on unseen values, sort of like an unseen examination for your code.
They usually contain a few tricky values to make sure that your code is robust and applicable to all of the cases for which it is required.
if more info needed: https://docs.codewars.com/training/getting-started/
This comment has been hidden.
This comment has been hidden.
i have a doubt on this test case isIsogram
this should return false, since there are repeating letter (s)
but it fails, dont know why
tested you code and it returned False,but it gave me one i instead two (i,I)
i and its count 1 s and its count 2 False
i would converted the input string into either lowercase or upperase and then do the count ( in this test the letter case does't matter) also, you only check one condition --> if chars.islower(), so the code will miss (upper case I)
I see several issues with your code:
not a suggestion
I was attempting the problem in c++. I'm not sure if I have include the libraries myself, coz I tried using toupper() function and there is a weird error shown.
Yes, you need to include the libraries yourself. Read this too: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution
This comment has been hidden.
Mark your post as having spoiler content next time, please.
Sorry Chrono, I will next time if I post any code. Cheers
Dont Demotivate yourself, Cheers that you made it in the end It takes time to learn something new or to scratch your head very hard.
I just realized the cap letter 'o' looks alot like zero 'O'!
that was a funny this kata
This comment has been hidden.
Please see if this section of FAQ is helpful, it contains a bullet point related specifically to your problem.
This comment has been hidden.
It took me forver to realize that the O in moOse was not a 0 (zero). I might suggest for future test that the character is ambiguous and may confuse someone (as it did me). I was left wondering why on earth my code was passing and then it hit me after 10 minutes... it is a capital 'o', not a 'zero'. The words 'otTer' or 'lettEr' or 'meMory' might be more apparent.
It's written that these strings contain only letters.
This comment has been hidden.
Stop posting solutions where they don't belong or you'll be eligible for ban!
Sorry, friend... I'm new here, I won't do it again. :)
No problem. You can use snippets of code when asking for help, but posting full solutions is against what this site is about. Remember to mark you post with 'spoiler' flag if it contains revealing information.
Ok, thank you!
when i tested my code i passed but when i tried to submit it it failed. Why?
Tests does not cover all the cases. Try to add test cases from "Instructions" to Sample tests, you will see what instruction you forgot about.
This comment has been hidden.
this task must have 'return' after "if", if it's false...else it will continue endless
and this solution is not correct!! try to use 'bollka' for example
Don't forget import classes that you use in code (for example java.util)
import java.util.HashMap; is not working for me or im doing it wrong ?
It's you doing something wrong.
Hello! Noob question: Is the test case code shown on the bottom of the screen meant to be a runnable program? Or is it meant to fucntion more like pseudo code, to guide your thinking and program writing?
Yes, the Sample Tests code runs your program with one case to see if your program works in that case.
Thank you for your response. So pressing the "test" button runs my code and the test code?
Yes, it runs that test suite which runs your code. You may edit this field to add or modify test cases to assure your program does what you want. Then you could press
submit
which will run your code against the complete set of tests including random tests. There may be things you didn't anticipate there, so make sure your code is robust.This comment has been hidden.
C#, JoJo reference in the comment ( Or it is reference to Pink floyd:) )
When i checked the input str itself is wrong , function is feeded with wrong input data for sample test case instead of feeding "Dermatoglyphics" it is feeded "Dermatoglyphicsisogram" So it is failed I just printed the logs of string what kind of input is feeding into this static function, see below message . So any thought How to proceed further , i am a newbie.
print chracter D print chracter e print chracter r print chracter m print chracter a print chracter t print chracter o print chracter g print chracter l print chracter y print chracter p print chracter h print chracter i print chracter c print chracter s print chracter i print chracter s print chracter o print chracter g print chracter r print chracter a print chracter m
There's one test case for "Dermatoglyphics" and another for "isogram", you probably mix up inputs of two separate test cases as one.
This same thing is happening to me, I am failing one test, but when I log, it should clearly return False, but says I should return True
This comment has been hidden.
Please read this. Returning in both if and else inside your loop makes it only evaluate the first char.
Ty that solved it
'Looks like you've solved it'
This comment has been hidden.
Okay, thanks. You'll be awarded the medal of honor for doing this.
PS: Don't post solution in the discourse section you're not supposed to do that. For now, I've marked the comment as a spoiler.
Thanks for reminding, I will edit my comment now.
(JavaScript) How long would you expect an entry level Jr. Developer to take to find their first solution to this problem?
5 mins
:open_mouth:
I need to practise more.
Don't worry mate. Took me two days...
We will get there.
cheers Juan
.
Hi all, the test cases are correct when I try it in my browser console.
But here it's failing
Can anyone help me with this?
Not an issue, and without any information, nobody will be able to help you.
shall show my code?
You can read through this FAQ first, and if it does not help, then yes.
I keep getting this error when i hit attempt: "Test Crashed\nCaught unexpected signal: SIGSEGV (11). Invalid memory access." What does this mean??
https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#appendix-a-exit-codes-signals-and-other-strange-numbers
This comment has been hidden.
This comment has been hidden.
Read this. See again the example with
moOse
Good first step is to recreate failing test case in your IDE, and debug from now on.
Ty, guys, my bad
Guys whenever i try to test my code. The output box turns completely red with no text or error message. The code works in my IDE but doesnt in the codewars ide. Can someone help me out!!!
Try refreshing the page.
Is this what you see?
thank you so much B1ts. It worked!
Which sadistic fk make this 7kyu
Never give up! Two months ago I did not even know what Python is. Today I managed to solve this kata in a messy way. Keep doing what you are doing.
This comment has been hidden.
This comment has been hidden.
I'm trying to practice Java at the moment and am a native python user. I was wondering what's the reason why you can't simply type System.out.println() to debug a problem? Whenever I use System.out.println(x), it amounts to nothing on the console.
System.out.println
should work in java tests, and, as a matter of fact, it worked when I tried it. Are you sure you get nothing printed? Are you sure you are not trying to print an empty string or something like that?mhmmmm
First time trying out "Set", I like it.
not bad
This comment has been hidden.
Mark your post as having spoiler content next time. Without markdown formatting Python code is specially hard to read when indentation is removed.
The error is pretty self-explanatory, inside your loop, you're trying to access an index that doesn't exist. Adjust your code.
Line 8 is erroring because word[x+1] is out of bounds
i created my fuction based on the isograms of all orders. without realiasin that they where only asking about isograms of 1 order. my mistake whas in follow the definition of this page of isograms than following what explicit asked the problem
This comment has been hidden.
Why are you posting a spoiler like that? Don't, it's not allowed.
My solution passes every test except one of the basic tests returns the statement "None should equal True". I assumed this is in response to the empty string edgecase but my solution does return true when the input is an empty string. Anyone have thoughts on this?
Hey , did you put at the first issue return "true" if the string's is empty? With me this work's!
This comment has been hidden.
This comment has been hidden.
quick question from a newbie...... how am i supopost to know? I mean I can google my way trouth the solution but isn't that cheating? Is there a better way to find this stuff out or do you all just google things? Thanks for any answer :)
That depends on what you Google. Are you just throwing in an answer and leaving it or are you then exploring other avenues.
I had a brain fart and and to Google how to check for an empty array in JavaScript :)
Instead of looking for quick answers on google, you can also try researching the documentation for your language. You'll learn a ton!
BIG HINT and advice (didn't think it was necessarily a spoiler since a bit of assistance in this nature isn't a solution per say, but open to opinions otherwise): Very tricky at first as I was confused why my array was looking at previous attempts and finding repeating values, but it might be because the pointer pointed to by unitialized array was being referred to over and over. Make sure you initialized your array (if that's the method you choose, similar to hashtable) every time you call it! ;)
Also the stdbool.h file is being included so "true" and "false" work (for those who are confused below).
This comment has been hidden.
spoiler flag, please...
Hi, steffan153, I am really sorry. I thought I had flagged it.
Rust translation added :)
This comment has been hidden.
Because you're abusing
sort
there (it's not stable in javascript btw), I think you wanted to use another method to compare the letters. Don't forget to mark your post as having spoiler content next time.Ok, sorry, next time i will post it as a spoiler context , I did not pay attention on that, thanks for info! I wanted to use this method, as I saw od mdn documentation I can make comparisons in argument with functions sort(). But I've just used another way to solve it. But it is good to know that I should not have abused sort methods. Thanks a lot!
This comment has been hidden.
(java) the provided solution class name should not be lowercase and there is an extra space before the name isIsogram
well done
My code logic is absolutely flawless, it passes the sample test cases, but when I try and ">Attempt", it shows me a failed case. Might have an issue with reurning booleans. The code works, thats for sure (since I checked it on my editor too.)
notice there are 1,725 solves in C++, so there's no problem with the kata concerning returning booleans
Yeah you are right, my code is broken, so is the editor and the "run sample tests".
Nope, just your code.
notice there are now 1,726 solves in C++, because I just solved it in C++ with
absolutely flawless boolean logicno trouble whatsoeverThis comment has been hidden.
Hi. When posting code, please mark it as having spoiler content, otherwise everyone on frontpage can see your code. Also format it properly (link here)
I don't know exactly how wrong it is, but I don't see you handling lower or upper case letters, to begin with...
Sample tests are just examples, there's a lot more tests run when you hit submit to make sure your solution is correct, and if you're getting errors, it probably means it isn't.
This comment has been hidden.
I'm really struggling to figure out what is it that you're trying to do.
Your code seems to be checking only adjacent characters, but they could repeat anywhere in the string.
That line just fills the array with holes when
if
condition isn't met, and theif
before doesn't make much sense.The first
if
makes no sense to me whatsoever, I don't know when it would ever be true.Fundamentally, the way you're checking for repeating characters seems to be way off =/
Also, when posting code, please use Markdown Formatting which makes code easier to read.
Thanks for the reply. Yep bad formatting, thanks for the link. In terms of checking adjacent characters that is based on sorting the characters initially with the Arrays.sort(arr) line. Maybe I need to just start over.
Ah, that makes some sense, but I think how you're checking it is not gonna work. I'd suggest starting over and looking at other ways to solve the problem, maybe there's some data structures that could help you o_O
OP solved it closing
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Because it's
length
notlenght
.... well thats embarrasing! Thanks Chrono, can only improve from here! :-)
Why have only one test with digit?
moOse
There is no digit there, that's a capital O.
You are right.
Typescript translation and Julia translation
When returning bools, C++ returns them as 0 or 1, NOT as true or false, and so I was unable to solve the Kata despite my program working correctly.
That's not a problem, in C++ true and false are aliases for 1 and 0, your code must be wrong. Post it with markdown formatting and marking your post as having spoiler content if you want someone to check it. Check your code handles capitalization right.
Whoops! I made a quite stupid error, thanks for reminding me to make sure capitalization worked, I found a broken loop. Forgot
break
only breaks from one loop.This comment has been hidden.
Clearly the above mentioned points contradict this point. Also description is shared amongst all languages, so changing the requirements of a specific language is not feasible, let alone the amount of languages and solves as of now ...
This comment has been hidden.
Don't worry about that, in C++ true and 1 and false and 0 are equivalent (for a boolean). Your problem is your code isn't ignoring capitalization, read again the example with
moOse
as input .one and the same letter but different registers is also a duplicate thanks .already fixed everything works)
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Your code fails with this test for example:
one and the same letter but different registers is also a duplicate thanks
This comment has been hidden.
Don't post solutions, it's forbidden.
Sorry, I didn't know (new here). Hope admins will delete my comment. I've no way to delete it...
Don't worry, I've marked it as having spoiler content and that's the best we can do.
Good
This comment has been hidden.
Don't post solutions, it's forbidden.
I guess i would have clicked the spoiler button two times. My bad, i am really sorry.
I have proposed one line solution. All tests are passed, and this kata is marked as completed in my profile, but I still not see my solution in "my solutions" for this kata. What's wrong?
Passing all of the sample test cases, but I keep failing the attempt. Not sure what to do from here...
there is a one-liner solution for this using stream, not sure if it is the best practice or the best solution performance-wise, but it is definitely readable and clean.
This comment has been hidden.
ok, i figure it out. empty String retuns false
"Ignore letter case." is a vague, and possibly contradictory, statement. Please clarify to something akin to "Assume upper and lower-case letters count as the same letter."
If you have to handle letter casing to reach the correct solution then you're not ignoring them, at least from a certain context.
The example in the description shows what "ignore letter case" means:
There are two
o
in"moOse"
(ignoring letter case they're equal).This example (a word with a letter that repeats in a different case, and no letters that repeat in the same case) would have been very helpful to have! It implicitly clarifies the statement. However I was very confused when I received your reply until I noticed that kata descriptions and test cases can also differ depending on the language it's viewed in. In my case this example is missing from the C++ description (and most other languages in fact), whereas it's present in the Javascript version.
C++:
Javascript:
Consistency is important! However my advice to other warriors reading this would be to check the other language test cases for hints, just in case. :)
Haven't noticed that difference, the languages I did this kata in had that example and I assumed they were consistent. Changed the description so all languages have the
moOse
example now.This comment has been hidden.
Not a kata issue:
It doesn't rerun them when you submit. Running sample tests are simply examples, to get the full test suite click 'attempt'.
If you run the code that I've provided, you'll see that Kata is incorrectly showing something didn't pass, when it in fact DID pass. That's what I'm getting at there. Try my code in your browser console and it will pass 100% of the time. Try the exact same code in Kata, and it fails. This one isn't resolved.
Try: isIsoGram("bncwxyfvesoriXljhmzputkgdaq");
Codewars returns: Expected: false, instead got: true Console Returns : false
It's a problem with your code, you're misusing sort. Use a better suited method for that. Sort is not stable in javascript. Try your code in repl.it and you'll see it also fails there.
Well holy crap. In all my years of screwing up javascript, that's the first time I've heard of sort() being so unstable. Sure enough, it was an easy fix. Thanks a bunch!
I am going through the log and I have outputted the correct response for every single basic and random variable (50 tests total!), but I am still receiving an error. What could I possibly be doing wrong?
Maybe you're printing the result instead of returning it? Hard to know if you don't post the error message or your code. If you post your code make sure you use markdown formatting and remember to mark your post as having spoiler content.
This comment has been hidden.
Your code should return the result, not print it, and also note you're returning strings, not boolean values.
I am using c++ version 14. the function always return 0 or 1. I driectly returned other values such as boolen(true or false), string, and int. it still show actual result 0 or 1. Any information?
Hello! I was trying to solve this code but it is always showing that the original ans is true and that my answer is wrong even if my code is returning true. Is there something that I am missing out?
Probably.
What language are you having this problem with? Post your code, marked up and as a spoiler, and inputs and actual and expected outputs. Help us help you.
Closing.
This comment has been hidden.
It's a problem with your code, not a kata issue, if you return in both cases inside your loop, you're only testing the first char.
I mean even when I write one line of code in the function such as, return true or return false, without anything alse, it still returns number 1(in the case of true) or 0(in the case) not boolen value true or false. when I directly return true or false from code, the actual result is 1 or 0. I could solve this problem but becuase of this, I can not complete this kata.
This comment has been hidden.
kata solution != kata suggestion
Disappointing lack of pigeonhole principle in the solutions I've seen. You want to make a set out of a million-character string?
Nice, no Turkey test
This comment has been hidden.
your empty string in the first IF isn't empty - it has a space in it ???
Thank you for your help! After looking it up i changed the IF to:
but it still won't work :(
//change to : if(str == ""){ return true; } //without a space
This comment has been hidden.