7 kyu
Always perfect
655 of 1,241bereket2015
Loading description...
Strings
Arrays
Mathematics
Regular Expressions
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 kata needs a checkup
6kyu
python new test framework is required. updated in this fork
Approved
I saw another user had previously reported this issue, and though it was marked resolved, it has not been resolved. For input "0,1,2,3", the expected return value is "incorrect input" even though the input fits the criteria specified in the description (four consecutive numbers separated by commas). If this is considered incorrect input because it includes a zero (which is my best guess), then the description should be updated to use either "positive integers" or "natural numbers" in place of the word "numbers". If this is not the case, then the test case itself should be corrected.
Regardless of the reason the test case fails, the word "numbers" is too inclusive a term to be used in the description. If zero is considered valid input, then the term "whole numbers" should be used instead.
Edit: This is for the JavaScript version. I'm not sure if other versions have this issue as well.
Kata author is inactive; I've forked the kata to update the description here:
https://www.codewars.com/kumite/64ffa41a3ee3383073c42677
Would appreciate review.
This phenomena generalises over all integers, not just the naturals as expected by the test. If I were writing this from scratch I'd definitely extend it at least include zero, but I'm not and doing so would invalidate existing solutions.
Description does not mention whether negative numbers will be tested
Also inconsistency regarding this part in all languages (No tests in JS, but some in Python, Ruby)
Validations in this kata are absolutely disgusting.
Ruby 3.0 should be enabled.
Somehow got the following complaint from the random tests (Ruby): "0-8,-7,-6,-5" It should work for random inputs too - Expected: "not consecutive", instead got: "incorrect input"
This comment has been hidden.
In the JS version... Why, with an input of "0,1,2,3", does the kata expected a result of "incorrect input" when that input seemingly meets the kata's criteria? It's exactly four consecutive numbers, separated by commas, whose product plus one is a perfect square (which happens to be 1).
Because the control function doesn't consider 0 as an integer. It should be either stated or corrected.
OP left the building, closing!
Python 3 should be enabled.
The random tests in Python generate values like
0-7
.Also, when this happens the reference cannot convert such value to
int
, and the error message gives away the solution.Ruby :
the random generator can sometimes produce numbers like "079" as a string which will catch some solutions which could be incorrect depending on how you read the description, but it is rare happening at most once in a few trials
the test suite doesn't produce possible edge cases just look at how I tested for non-consecutive numbers which worked but should not (1,1,1,3) will pass my solution but should not
Added the fixed case, knocked out my solution.
Closing the other as Python does the same and there are mass solutions and no-one is complaining.
awesome kata, personally i would have ranked it at 6 kyu but perhaps my standards are too low.
Help please !!! My code is failing the last 2 test in Ruby, I can't figure out where the problem is:
Expected: "25, 5", instead got: "incorrect input" Expected: "1, 1", instead got: "incorrect input" 18 Passed 2 Failed 0 Errors
I'm having the same problem, did you ever figure this out?
@ FuzzWorley, No I haven't, I left it in the hope someone will give me some hint. I do not want to unlock the solution :)
JS Version of Kata needs random test cases
Added.
Random broken tests:
These are invalid inputs.
Basically what anter69 said, but also with an additional test case for sequential numbers that don't all have the same number of digits (to break string sort solutions).
Doing 8 kyu katas so far, this seems a bit too difficult for 7 kyu. At least the checking of negatives/non-numbers is not simple without the knowledge of
try - except
(in python).On the other hand, you could/should check unsorted, but otherwise correct sequences (e.g.
1,4,2,3
) which would be valid, as those are 4 consecutive numbers (even if they are not ordered).Cheers
Two of the tests input strings ending with commas (ex. ",1,2,3,4,"). Not sure if that was intentional or not, but since it wasn't shown in any of the examples I'd suggest fixing that. Other than that I thought this was a really fun kata :)
Very frustrating to have Expected: 841, 29, instead got: 841, 29,
Any clue why this is happening? I've ran tests on my code and it seems to work fine.
hi, please double check and make sure returning result is number not string
how can it be number if it has a comma in it?
@Adrian1707 I was getting a similar problem. Resolved by adding a space after the comma.
The 4 real test I get this: 10,11,12,13,15 'not consecutive' should equal 'incorrect input'
To me that should be not consecutive.
the idea of this kata is, numbers will have perfect square root when they are consecutive and when the length of array is 4. So whatever array less or more than 4 will not fit to this ability, thus meaningless and that is why 'incorrect input'. hope it helps!
completely missed the length of 4 part, like I literally just read over it. Sorry about that. Thanks!
it is ok cheers!
I edit my solution and find a way to make the first test of the "submit test" pass. But notice in the second test this:
#From the Submit test
The different I notice is a miss comma (,) in the test answer.
But in the regular "test" you need a comma to make this answer correct #Line from the regular test
BTW I really enjoy this Kata :) And I learned a bunch of thing while solving this :)
'not consecutive' should equal '25, 5' 18 Passed 1 Failed 0 Errors
I think there is some error with test. In my python shell for string '1,2,3,4' the output is showing '25, 5' which I think is the only possible case for getting '25, 5'. Or... is there the possiblity of negative numbers? like '-1,-2,-3,-4'. I have tried all possiblites like: '4,5,6,7' '4,5,d,7' '10,13,12,14' all are showing expected results.
Hi bdarksider, If numbers are negative it returns incorrect input, if among numbers you have character other than number it returns incorrect input. The JS version works in this way. In which language are you solving the task?
python
Negative numbers are also tested, but I think a mere
print
statement should solve your doubts :)This comment has been hidden.
this is the message I see when submmit
hi sempjc, what was your input in this "Expected: incorrect input, instead got: 257,401, 507.34,702,127,833,566" case?
hi sempjc,
there is clarification for you, i have just made some changes to the solution function, so now how it works for JS version: numbers given must be positive integers not doubles -if numbers are positive but not consecutive it returns 'not consecutive' -if numbers has among them at least one double number it returns 'incorrect input' -if numbers has among them other character than number it returns 'incorrect input' hope it helps
I don't know what was the input from this case, because this was the result of hitting the button of submit. I asume this is the first test of the "submit test"
But I find a kind of logic error on my code and fixed. Then this first test pass.
I was evaluating:
if(s.length < 4 && s.length >4 || "and a test for verify they are all number")
this work in all the regular test.But is wrong because nothing can be greater and less at the same time. So I make a simple evaluation like
and make work fine in the "submit test"
hi sempjc, one trick if you would like to see what was the test case simply add console.log() at the beginning of your code which prints argument given to the function.
so did you manage to solve the kata afterall:)?
Thank for the trick :D I never thougth of that. Well they work better now, but now a notice a missing comma on the Ouput result. I write in another post what a notice. #This is the Output from submit test
#This is the output from the regular test But in another test I need the comma to make the answer correct:
happy you completed kata successfully:)! cheers!
Upvoted, approved, translated (Ruby and Python, as usual) and I must say solving this as a one-liner was quite fun: thanks :)
Oh, I forgot: you may wish to remove the tests in JS with too large numbers, as JS is rather prone to precision errors past the 15th digit.
Hi Giacomo,
Thnaks for upvote! Once it is out of beta status i cant unpublish it and make my changes, can i? About translations I can not see '+' sign next to this kata.....?
Sorry :) i didnt notice huge '+' sign in front of me :))) translations approved many thanks! First question is remaining unclear still
You can change anything you like until you have less than 500 valid submissions.
Then you can change anything but the full tests' page.
I removed too large numbers, thanks, cheers!
The test cases are completely broken, they always pass, no matter what I return.
Hi kayahr,
can you specify, what did you pass and what it returnded. clarify your problem, what exactly happened? then i will try to figure it out.
Simply do this:
Then hit the
Run Tests
button. All tests succeed.Test.expect
only checks if the returned value is truthy.Tests are fixed now