We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
In my solution, bolded parentheses evaluate to zero (-1/-1+1*1*-1 = 1 - 1 = 0), and then further evaluation fails because of division by zero error (-1*1/0*2).
Can someone explain the logic behind this, because it is written that there will be no divisions by zero in any test cases?
EDIT: When I redefined the modular inverse of zero to be zero, which is mathematically incorrect, it passed all the test cases. I think that four of the test cases are bad.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Expressions V2
You are viewing a single comment's thread. Return to all comments →
One of test cases contains this term:
-1*1/(-1/-1+1*1*-1)*(1--1)
In my solution, bolded parentheses evaluate to zero (-1/-1+1*1*-1 = 1 - 1 = 0), and then further evaluation fails because of division by zero error (-1*1/0*2).
Can someone explain the logic behind this, because it is written that there will be no divisions by zero in any test cases?
EDIT: When I redefined the modular inverse of zero to be zero, which is mathematically incorrect, it passed all the test cases. I think that four of the test cases are bad.