Would it be possible to sort community solution by compactness?

Most of the time I wonder which community solution is the best in compactness.

Usually it goes down to how good you abstracted the problem and shows clever ways of using specific strategies depending on the language used. It would be great if we could “sort” community solutions by the number of line.

Is it a wanted feature ?

1 Like

That would be a good option. Not every track implements a “lines of code” counter (it relies on an external tool), but a raw number of lines could be used instead. Keep in mind that more compact solutions may be correspondingly more difficult to read.

On the one hand, simple, clean solutions are often shorter than complicated approaches. On the other hand, sometimes people engage in code golfing and make solutions really short and incredibly challenging to read. Lines of code can be an indicator of good code … until a point, after which, fewer lines may mean harder to read.

Sure and that is very true when the language allows you to write everything on one line but that also avoid to get 5 pages of people using every term of a geometric sequence to compute its sum instead of the one-line mathematical formula.

In short I know it’s not ideal but that is still a worthy sorting key don’t you think ?

To sort by LOC is probably more achievable than to filter solutions by keyword. To filter solutions based on what they contain is something that has come up before. For instance, it may be likely that a solution using chained iterator function calls will have a shorter LOC than one that does manual updating of variables in a loop. So, one might have a better chance of finding a solution using, say, filter or map by sorting on LOC ascending, given the absence of being able to filter solutions based on containing the words filter and map.

I like this. We’re also planning on ordering by someone’s per-track reputation by default (so mentors’ and maintainers’ solutions will likely float to the top).

3 Likes