6 kyu
Range function
725 of 1,407wichu
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 could be an interesting pattern-matching problem, but right now it's just a trick about whether you read the order of two very similar words
There seems to be some issue with this kata, I get: Expected: '[1]', instead got: '[]'. But I don't undertand why because right before this line I get another message that the test passed with expected value [1].
tests are independent from each other. each green line that you see in the output panel is a distinct test. print your input if you want to know which arguments make your code fail. i added some logging to your code and i see:
check this
In Prolog, when running the test cases for the 'range' predicates, the tests are returning a list of a list instead of a single list. For example, for
range(5)
, I would expect the result to be[1, 2, 3, 4, 5]
, but the test returns[[1, 2, 3, 4, 5]]
.It seems the issue lies in how the 'findall/3' predicate is used within the tests. It actually collects the resulting list of the 'range' predicates in another list.
I think you have the tests backwards. Your predicate is expected to behave like a generator, and produce single values at a time. The tests check for this by gathering all the values produced into a list. Your solution however produces one single list of all values at once, so the tests collect that into a list, creating a nested list, while the expected result is just a list.
You need to rebuild your solution to produce individual values. Eg instead of this behaviour:
You need behaviour like this:
Thanks for the clarification. Seems I misunderstood the problem instructions.
Expected [2,5,8,11,14]: [2] should equal [2, 5, 8, 11, 14]
expected input from description:
Hello, I have this error in the test 'Expected: '[]', instead got: '[2]'' but I can't see what parameters the test is passing to the function.
Print the input using
console.log()
.Lua translation !
Prolog translation
Approved
python new test framework is required. updated in this fork
Approved
Python version doesn't require the user to implement a generator (nor return an iterator which should be a reasonable alternative IMO).
In Python, the kata asks us to create a generator function. However, this is not tested at all. Even the reference solution is not a generator function.
Fixed
Did you just modify another person's five-year-old kata thereby rendering almost all existing solutions obsolete?
Which one do you prefer?
The latter is a better option IMO.
@Wei-Ting%20Yang:
your change is very unfortunate, because returning a
range
object doesn't pass the tests, while it is what is explicitely asked forwell, reading the description again, your change is actually totally inappropriate... never the user is asked for "a generator", the only expllicit part about that is "return an iterable". The first sentence is to be read as
return a function that generates ranges
. Please revert your changes (you could update the description on your way, so that the confusion is avoided).IMO the better change would have been to simply remove the word "generator" from the description
probably, yes
The description literally says "create generator function", and the author's solution is a generator function...
no, the first part is subject to interpretation, depending on how you read the sentence
btw I believe that standard practice now, is to use the fork feature to repair katas. That will allow someone to review the changes before approving.
This comment has been hidden.
.
JS:
This is not enforced. You can just directly return an array and passed.
And arrays are not iterable objects? The real problem here is the fact that
range
can be a regular function when it's supposed to be a generator.Yea, that's what I meant. It should be a generator.
Nice twist having a variable number of arguments to deal with!
Example is not a specification.
For the description, can it be noted that which of the arguments is the start value, step and stop value? It's not clear, so requires the user to refer to the examples to figure out which is which if one or more are not declared.
Consider adding a few sentences like: "When one parameter is defined, assume it to be the stop value with a step of one. When two parameters are defined, assume they are the start and stop values, respectively, with a step of one. When three parameters are defined, assume they are the start, step and stop values, respectively."
Thanks
Python: The description asks for
an iterable
but the tests only accept instances oflist
.This comment has been hidden.
My bad, sorry, all sorted :-)
Thank you!
This comment has been hidden.
This happend a couple of months ago. It turned out to be an error within CodeWars :-)
Thanks for letting me know I've changed it and will check all my other translations :-)
EDIT: actually this may of been my error in this case, looking at the original translations, whoops, sorry everyone :-)
I agree, the range function should be forbidden.
Ruby and Python translations, please check and accept :-)
i'm passing all basic and random tests except basic test #6. is there a way to see what that test is so i can figure out what i might be missing?
Same here. What was the test?
same here.