How's Shortest Code Solution Defined?
how's shortest solution defined
there are many different ways to consider what is “shortest”.
- counting by lines → not good. because a lot of it depends on formatting.
- counting by character → not good. because long function names suffer. (APL here wins. because in APL, every function name or operator is one single character.)
- counting by tokens (syntactic units) → better.
- counting by atoms → this can be done easily in WolframLang. you consider your code as syntax tree, and count the number of nodes.
Normally, people go by counting chars. Obviously, that's idiotic. Cuz then long function names suffer. Such as WolframLang, lisps (except clojure)
rather, a function name should be considered as 1 char.
and among coding competition in WolframLang, they count shortest by counting the number of nodes in the code. eg the code is considered a tree, each atom in the code, is a count.
this is the most sensible for “shortest” code, in the WolframLang case.
but doesn't apply to C or others, cuz in these langs, you have statement, and syntax... they no form a tree, nor a unit. basically you just have char soup.
in C java python etc, you might count by tokens. yes. i think that'd be best.