8 kyu
Is it a number?
2,977 of 16,535provector
Loading description...
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.
This comment has been hidden.
This comment has been hidden.
Lua translation!
very bad kata
Main problem I do not see what falls this test. I see only problem, it do not show me 's', if i return 's' I so not see what my function do. I return 's' and return all 'false'. I do it. but for it need very much time. decition have ony one string, but you do not see it, if you do not know basic funtion for it
Something is wrong with the basic tests (all randoms passed)
I printed all of the ones with a result of false, but as per the description they shouldn't be true? (Added an extra condition to make the -0 into true and still fails..)
"s2324" false "3 4" false "3-4" false "3 4 " false "-0" false
You've hadcoded the answer for several input values, but not all, read the error message:
Your code isn't failing the test of
-0
, it is failing another one, but as your code is wrong, it is not a kata issue. Make some code that works at least without hardcoding every test and only then open an issue if you're sure there is a problem with the tests.This comment has been hidden.
This comment has been hidden.
All tests pass, one fails. Shit! What do I do? I'm upset! Very upset!
I test it and all basic tests pass. I attempt it, and no basic tests pass but all random tests pass. JS. Fix pls;
Your solution fails for
s = " "
.Not a kata issue.
This comment has been hidden.
Scala translation
approved
python new test framework + snake_case + backward compatibility + updated random tests are required. updated in this fork
Approved
This comment has been hidden.
They don't return the same for empty string as you claim, and that obviously is not a digit. You're wrong.
Okay but still it's an bad kata as the attemps don't show any empty string to try. So how would you know what is wrong.
Printing the input: https://docs.codewars.com/training/troubleshooting#print-input
Sample tests are just that, a sample, it won't show all edge test cases.
I test it and all basic tests pass. I attempt it, and no basic tests pass but all random tests pass.....
This comment has been hidden.
When someone writes a kata, he doesn't decide the rank it will get attributed. See there: https://docs.codewars.com/concepts/kata/beta-process/
This kata does not contain tests like these: " 4 ", "abc-4.56cfff", "-45.45.3"
test data does not contain examples with multiplie dots. such as "3.5.5".
that's right , you can add a counter for'.'
this is just not an 8 Kyu. the fiddlyness of it and concepts are beyond beginner.
Description should be language-agnostic
This comment has been hidden.
This comment has been hidden.
I spent some time just because of 1 anoying input. There's one special case.
This comment has been hidden.
Please read this paragraph first: https://docs.codewars.com/training/troubleshooting/#post-discourse And then this one: https://docs.codewars.com/training/troubleshooting/#works-but-no
Thanks for assitance!
@provector I see you've logged in this month - is there any chance you'd be willing to improve the tests of at least one translation? There are no tests for multiple decimal points, what about comma vs period, what about 10e7, what about ".0" and "0.", what about languages with different ideas about what a valid float literal looks like?
Currently, solutions that think
"...."
is a number pass, and probably a bunch of other similar things - it would be good if a beginner kata was a bit more accurate because beginners themselves are likely not to be aware of that their solution isn't right.Hey, sorry I wasn't here in a while, things with life and work are crazy right now :( I see you have 2kyu, would you be willing to clean up translations with broken tests? I only wrote this kata in Java originally (never knew it would get so popular), so most of the translations are 3rd party. What Im trying to say feel free to "admin" on whatever you see broken :) Can I give you some extra permissions to meddle with this Kata?
This comment has been hidden.
C# (translator last seen 3 years ago)
misuse of IsTrue assertion here:
Assert.IsTrue(CodeWars.IsDigit(input) == expectedResult);
this will end up saying it expectstrue
even when it expectsfalse
random tests are also lacking, too easy to hardcode
if (x[0] == 'f')
or something like that, maybe some other language has a better test that can be translatedThis comment has been hidden.
isNaN is entirely unrelated to whether a string represents a number it answers the question of whether a value is the particular value
NaN
you could of course hope that failed conversion to Number results in
NaN
, but, yikes.(also, redundant ternary, it turns
true
totrue
andfalse
tofalse
, you already have that same without boolean applying that operation)Hello. I have a question I would like to ask the community:
is it useful to handle exceptions? because I notice that when I try to convert the input of the function (the string) to float, I can't when it's anything other than an int. so I suppose we have to adapt the condition to take into account the case where the string is not convertible to floating or integer. therefore exceptions must be handled. could someone tell me if I'm on the right track?
thank you for your possible feedback.
This comment has been hidden.
Yes, you're on the right track. There multiple ways to handle that kata.
This comment has been hidden.
There are 2 Basic tests in Sample tests (that's why it's a sample) and in Submit, there are 11 Basic tests.
C++ translation kumited
This comment has been hidden.
Total n00b here, but i'm struggling to understand the various test results required. On the log it states: expecting "ab" to return true. Also expects "" (no input as far as i can see) to return true.
How are those valid integers or numbers while zero (another string) is expected to return false?
You're misreading the logs: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#print-input
Assuming that's an automated reply. I've read that link. How am I misreading these results?
1: Expected: TRUE, instead got: false Log
false
2: Expected: TRUE, instead got: false Log ab false
The order is (as it is shown there):
You're misreading it:
And, no, it takes time to check the tests and to explain this (it's not an automated reply).
this kata is a piece of crap , I added a print at the top to be able to debug the output and add a couple of if's to account for some cases. Ugly solution but it workds
This comment has been hidden.
This comment has been hidden.
test 7 and 8 i cant pass but other 407 is okay and i cant even guess what the tests ((
Correctamundo!
it would be nice to know which tests we got wrong instead of having to guess so we have a better idea of where we went wrong.
You can always check test input by printing it: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#how-can-i-see-which-input-causes-my-solution-to-fail
anyone know how to identify negative numbers in strings?? I dont want to lstrip() or say if it is +/-. I just want to say, if there is a negative number in this string to answer True.
Math.sign(num) will return -1 if the number is negative I think.
you can use stof() or stod() functions they both can handle -ve signs as well as decimal points.
This comment has been hidden.
Your code fails, that's not a kata issue. Read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#print-input
this kata is 7 not 8
This comment has been hidden.
Probably input like ""(no symbols) and " "(only space), failed. I had been same problems. Try to add check on this tests.
87% satisfaction prbbly has to do with it being 8.6 kyu (?) lol
This comment has been hidden.
Use
System.out.println(s);
to see why.This comment has been hidden.
Why tests say "True should equal False"?
Because True is not a number.
Your solution returned a wrong result.
Yeah but the test did not mention which string was tested, so no debugging is possible (at least in python)
Print the input yourself.
This comment has been hidden.
Not an issue.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
'Looks like you've solved it'
This comment has been hidden.
The argument
s
passed in is a string not a number, you need to test whether the string represents a single valid number.Comparison operators such as
<=
and>
coerce their arguments to numbers, if necessary. ( If this is, indeed, JavaScript. )Coercion has some subtleties though, that's very probably what's biting you. If you're new to coding, it is probably better not to rely on coercion; there are other ways with fewer subtleties, that will inflict fewer bugs.
This comment has been hidden.
CW GitHub Wiki - Kata Best Practices - Follow Established Conventions
[Python] Name of user solution should be
is_digit
notisDigit
(source: PEP8).As a side note, I don't get why the function would even be named "is digit" in the first place? We're testing whether the given string represents a valid number (which more often than not contains multiple digits along with an optional decimal point and/or a negative sign), not whether it represents a single digit.
good point
True. A better func name could be is_numeric I suppose.
fixed in latest fork after 6 years
I added a translation for C# if anyone is interested in having a look at it.
"alr approved some time ago"
This comment has been hidden.
Usually you can write to standard output of some kind, the exact way depends on the language. For C# it's
Console.WriteLine
, for Java -System.out.println
,console.log
and similar for JavaScript etc. You can see the program output in the test output window.Below the code editor there's a
Sample Tests
section. You can see the basic tests there. If you want to find out the inputs of the main tests, you shouldSystem.out.println(argumentVariable)
inside the function to see it.By the way, you solution doesn't work because the input is a string, you can't subtract strings.
https://www.w3schools.com/js/js_type_conversion.asp When JavaScript tries to operate on a "wrong" data type, it will try to convert the value to a "right" type.
( JS )
My solution would reject
1.
as well as1e3
, both of which are valid JS numbers.This is probably intended to be a simple kata. The subject matter, however, is decidedly unsimple because of certain .. subtleties. If you intend this to be a simple kata, you're going to have to write some very exact specifications.
I want to follow up with a specific example. I was able to get 410 of 411 tests to pass. I have one test that will not show me an outcome via console.log and still fails. No idea where to go from here. On a level 8. I was able to get one other with no console.log output working.
If anyone wants to point me in the right direction, I would appreciate it.
Print not just the input, but also the type of the input. If it's a string, also print the length.
This does not really have anything to do with this issue - the input is very probably correct in this specific case ( if it is what I think it is, that is. )
Thank you Johan. I was able to get all the tests to pass after your tip. All the best. Chris
This comment has been hidden.
This comment has been hidden.
The error message says
should equal False
. So what do you think, are those ELF binaries or not?This comment has been hidden.
The way you're overcomplicating this task is insane. Could you post your code please? :)
A MATTER OF STYLE AND EDUCATION: Hey you, please leave words like 'insane' to your own presumption or miseducation!
Here you are supposed to have a decent and respectful way to address things, even dealing with the frustration of people like me who is facing a new language for the first time and doesn't have a clue about technical, specific difficulties.
A MATTER OF SUBSTANCE: Also, how could you be that sure that I'm overcomplicating the solution if you have no idea how I approached it?
Better to climb down from your 2 kyu stairway to heaven and consider that I simply stated that I've never met a xx.yyyyyELF kind of type before, which is not reported on any online source as well. It seems there's nothing 'insane' in this.
Thank You, Best Regards
First of all, saying "Hey you" is impolite. Secondly, I haven't said a single bad word towards you to be called "indecent and disrespectful" in return. Thirdly, Python is list among your "skills" in your profile, so you're either lying me or yourself (well, this doesn't matter in fact but whatever).
I don't have to know exactly what code you've written (though I do really want to, that's why I'm asking you to post it in a spoiler), but I surely know that your thinking and reasoning is beyond what one would define as logic, and that's why I'm saying that you're overcomplicating the task extremely.
By the way, if the RNG generated incorrect values like this:
str(random_number) + "abcdefghi"
, would you also search on the internet what is"abcdefghi"
in Python?no need to be oversensitive either, Hyrundo... ;) ELF are nothing more than caracters. So think about what you should do with that kind of input.
EDIT: crossed messages
FArekkusu,
FIRST: you're wrong. 'INSANE'? If you presume that someone else has an 'insane' approach, is it an acceptable or educated way to refer to another person? No, man, really, I wonder how on Earth you grew up... the minimum you could expect is being replied 'impolitely'. WORDS are important in human communication. Mind about that.
SECOND: I'm not lying - you see? After 'insane' you are also quoting me as 'liar'... you know? You ARE disrespectful and impolite. If you simply read, my level in Python is 7 kyu, that after less than 15 katas, which means what in your mind? Am I an expert? Or am I lying? I'm trying to learn this new language since 2 weeks ago.
THIRD: do you want a DEMONSTRATION from yourself? Quote: "but I surely know that your thinking and reasoning is beyond what one would define as logic," You know what, big mouth? You are a presumptuous and full of himself, self centered, empty BIG EGO. So after 'insane' and 'liar' now 'stupid' is your third implicit guess?
You know what?
Your words qualify yourself for who you really are. Either you learn respect and education or simply you go back to school about a basic understanding and usage of the human language, which you don't even remotely master or understand properly.
Grow a thumb if you can.
To Mr. blind4basic:
thank you for your explanation. I was wondering if that final 'ELF' could be a native Python symbolic way to address a scientific decimal notation. But - as you mark out - that is not the case.
Also, as a very unlikely coincidence, it happens that Python has a type called 'ELF binaries':
https://python3-pwntools.readthedocs.io/en/latest/elf.html
With Best Regards
Your message is the definition of nonsense.
You can think whatever you want, but take a moment and ask yourself a question - what you should and shouldn't say.
увидимся, Cаша, научись читать
Hint: you can skip a kata if you can't solve it.
Or you can also forfeit it too, it's just an
8kyu
anyway ;-)This comment has been hidden.
JavaScript translation submitted, if you want to approve it :)
Great Job, I'm trying to but codewars seems to be crashing.
This comment has been hidden.
That's something you would have to bring up with the codewars admins, cata creators have no control over the scoring system.
PHP translation added.
I'm trying to approve but codewars seems to be crashing.
isDigit is confusing a bit because digit is not the same as number ;)
Ha, fair enough :) though I'm sure coders will figure it out on the way ;)
This comment has been hidden.
They're not numbers.
This comment has been hidden.
This comment has been hidden.
I didn't do the python translation, whoever did should answer that, I wouldn't have a clue. Sorry bud.
Not an issue
Good kata, but need to add some tests like a
-3.
,50.
etc. My solution was applied, but returns true with examples above. Good luck furtherThis comment has been hidden.