-
Notifications
You must be signed in to change notification settings - Fork 4.8k
alternateSign function #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Nevermind, I see what I did. It was a simple ternary statement. Although it is very strange that I could still pass those test with incorrect values. Sorry about that! |
Thanks for messaging me, @romcar. I'm glad you figured it out on your own. Do you mind providing more detail for the false positive you received? It looks like there may have been a bug in Chai's deep equality assertion. I'm wondering if you came across a case where their algorithm for checking deep equality failed. |
Well here's my code:
I checked the chai code and it tests to see if the array starts with a positive number. With my code, as the problem recursively flows it determines the sign of the element in the array according to the length of the array. Right now my arrays come out starting with negative values then continuing alternation from there. The second if statement (array.length) can be switched to === to make the array being with a positive number. But the test will fail. I'm sure it's a bug involving the deep equality assertion. No matter how I changed my code it will only pass if the alternation is neg, pos, neg, ... |
Is this your corrected code or the code that returned the false positive? @romcar |
It was corrected but returned an error. So I changed it back.
…On Thu, Apr 12, 2018 at 8:30 PM Richard May ***@***.***> wrote:
Is this your corrected code or the code that returned the false positive?
@romcar <https://github.com/romcar>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#57 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AecupNrlMOkilBi1u7pTecdhqglM_Ysoks5tn_GMgaJpZM4TRIrt>
.
|
I ran the code you provided above and it returns the correct output. Can you help me produce the false positive you saw? @romcar |
When I type in:
|
For an input of This is not an input I included in the tests, so it can't be a bug in the tests. The tests I included are intended to be a guide, but don't account for all possible edge cases. If you want to add tests to account for some edge cases, I'd be thrilled for you to make a PR and I'll review it. |
I accept the challenge, when I have more time as of right now I'm super busy. Sorry to take up your time. Thanks for responding though. |
Hello,
I'm working on the recursion prompts and noticed that the test being done on alternateSign are not working according to specifications.
After completing the function I noticed that the first element being positive gave off an error. I adjusted the functions code to make the first element in the array negative and then alternate from there. I guess I just wanted to let someone who made it know.
Regards,
Erwin
The text was updated successfully, but these errors were encountered: