There are lots of questions about whether to count the bytes in an import statement, etc. This question is not about that. Instead, this question is more inline with this question but I think it would be considered off topic/distinct.
Again, assume standard library imports are allowed at least, and that the byte count of the whole import is included in the score. The question arose here where many languages have libraries that provide a ready made solution. Now, is importing the solution enough, or does the required function need to be reassigned or evaluated?
When considering the consensus about builtin functions, it seems builtin solutions are acceptable in two situations:
- The builtin is evaluated.
- The builtin is assigned to a new name.
My gut feeling is that just importing a library is the same as doing neither of the above and claiming the builtin solves it for 0 bytes.
For instance, in Python, the NumPy library provides the function eye
which returns the nxn identity matrix.
from numpy import*
seems like cheating, but by the wording of the other discussion, I think it could be argued that it's valid.
My gut feeling is that this should not be allowed, but by the wording of the discussion about builtins it looks like it should be. Look at the wording of these two articles assignments and imports:
Assignment statements are used to (re)bind names to values
- Assignment
The import statement ... searches for the named module, then it binds the results of that search to a name in the local scope.
So is
from library import func
equivalent to
func=builtin_func
and therefore acceptable as an answer? And if, technically, it is, should we put it on the list of banned loopholes?