Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
The kata states input will be a non-negative integer. In cases like these I assume the validation/input scrubbing has happened before attempting to call the function.
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.