I'd definitely want to have some input validation and filtering in place before hitting the eval. Despite what others say about the evils of eval, it's perfectly legitimate to use if, and only if, you know fully what you'll be feeding into it and that it won't crash your code, so filtering to test for NaN inputs, and/or wrapping in a try/catch block should be the case here.
Very clever solution, and well noted from the WP article the congruence formula. Wouldn't like to see this in Production code though without comments in place explaining the formula.
This comment is hidden because it contains spoiler information about the solution
Love it. Way more succinct than mine.
This comment is hidden because it contains spoiler information about the solution
Good bit of code golf. But definitely wouldn't want to come across this in a production codebase.
Love it.
I'd definitely want to have some input validation and filtering in place before hitting the eval. Despite what others say about the evils of eval, it's perfectly legitimate to use if, and only if, you know fully what you'll be feeding into it and that it won't crash your code, so filtering to test for NaN inputs, and/or wrapping in a try/catch block should be the case here.
Nice and clean solution.
Very clever solution, and well noted from the WP article the congruence formula. Wouldn't like to see this in Production code though without comments in place explaining the formula.