Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

[QUESTION]Whether to pay attention to parameter checking and exception handling #207

Closed
zhangfelix opened this issue Jun 20, 2020 · 1 comment
Labels
question Further information is requested

Comments

@zhangfelix
Copy link
Contributor

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

from functools import reduce
from math import gcd

def lcm(numbers):
  return reduce((lambda x, y: int(x * y / gcd(x, y))), numbers)
@Chalarangelo
Copy link
Owner

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.

@Chalarangelo Chalarangelo added the question Further information is requested label Jun 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants