Closed zhangfelix closed 4 years ago
Hey there!
The decision to not check for errors and edge cases was made a long time ago when we started these projects and the reason behind it was to keep them simple and showcase interesting techniques and ways of thinking. All snippets expect the user to have a basic understanding of the problem, the language and potential errors that might occur, thus we are not adding exception handling or parameter checking to snippets.
Thank you.
Should we pay attention to parameter checking and exception handling, or should we focus more on showing a possible idea for solving the problem?
For example in lcm.md, the current implementation has the potential to cause a divide by zero exception.
Also, by definition, lcm should be a positive integer. However, the current implementation may result in the return of a negative number.
Current implementation