7 kyu
sum_eq_n?
257 of 256jastuccio
Loading description...
Arrays
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 is a duplicate.
@cliffstamp So you've just confirmed the issue and closed it? The random tests can generate it, but they don't do normally.
My solution doesn't account for such a possibility; I've just ran 10k random tests, and didn't fail once...
Is this an actual issue? The description explicitly mentions "two array elements", but not "element can be added to itself":
That means incorrect solutions pass the tests. https://www.codewars.com/kata/reviews/54b68cae11ac24e93900008c/groups/5bf125a829354d3ad9000210
None of the tests check for a number plus itself for example Test.assert_equals([1,2,3,4], 2), false 1 + 1 = 2 is true, but the number 1 only appears once, and should not be added to itself
just came here to post the same issue.
The randoms can generate it.
too few test cases allows answers that would fail the requirements with certain arguments.
Random tests added. Could you resolve the issue if the test cases are good now?
.
It's not clear what to do when given an empty array with a sum greater than 0 vs a sum of 0
An empty array will only return true when the sum required is zero. Added an example in the description.
.
I thought it would be fun to create a kata and I appreciate all the feedback. My current career path has unfortunately taken me far away from Ruby :( Is there a way to let someone take over this kata so the issues can be resolved?
This comment has been hidden.
The last case was very annoying but made sense, it was just unclear. I'd really prefer if this was elaborated a bit more.
There are contrasting errors on this Kata Passed [], 0 an empty array should be equal to zero for this method - Expected: true, instead got: false Passed [], 0 an empty array should be equal to zero for this method - Expected: false, instead got: true
The second test case was checking
[], 1
instead of[], 0
which should return false. Fixed the error message..
This comment has been hidden.
The "empty array sums to 0" condition is really weird. Do other things sum to zero ever? It feels totally arbitrary as stated.
Can you count same element multiple times? Does it mean 2 elements (except that weird [] 0 thing), or "up to" 2 elements (and then [] 0 makes some kind of sense)
This comment has been hidden.
Would be good to have more information returned when a test fails (took me a while to figure out that I hadn't catered for the last option)
Thank you missbassethorn. I added messages to the tests. Hopefully they make sense and will help out anyone else who has a failing test.
sum_eq_n?([], 1)
=> falsesum_eq_n?([1], 1)
=> truesum_eq_n?([2], 1)
=> falsesum_eq_n?([1,4,-1], 3)
=> trueI added some of your test cases. I don't have alot of time today to work with this. An arry with one number passed in might be invalid.
The part about the empty array doesn't seem logical to me. It doesn't have two elements to pick.
That quibble aside, I noticed the kata doesn't test sum_eq_n?([], 1). I messed up on that in my solution and still passed.