Shortest Mode

I find this mode a bit finnicky, especially since it punishes a lot of coding languages heavily while rewarding other coding languages. It also promotes weird behavior like deleting spaces and comments which often cuts off more letters than actually writing optimized code.

I don’t know which of these are feasible, to implement, but I would like to see:

  • The text count does not include extra characters, specifically: tab, newline, space (there might be others that I’m unaware of)
  • Comments are not counted in the text count
  • Any import statements (i only know what they are called in java, not sure what they are called in other languages) are not counted (This is admittedly a questionable suggestion since it might unbalance other things)
  • For languages that require a main class and some sort of main method, these are not counted. (The issue here is that these two lines themselves often take up more characters than the code that runs the algorithm, which means you start off with a guaranteed loss)
2 Likes

Good suggestions.

Maybe even have like a “handicap” based on the language used — like in golf — so there would be an actual chance that a c# programmer could beat a python programmer.

And just to clarify I’m talking about in real life when a really good golfer plays golf with a really bad golfer and they have a handicap so that the really good golfer starts out with extra points or something like that. I don’t really know all the rules of golf but I know that they have a point system so that people of different levels can play against each other.

As far as I know, C# 10.0 no longer requires this, and CG recently upgraded to this version.
Regardless, your suggestions make sense.

It’s more complicated than just not count some things.

If you don’t count the imports, you’re gonna import anything to use existing functions. Golf has to make you choose between the cost of the import or the cost of writing your own function (example in C# where your have to choose between using Linq or a for loop).

If you want to win a golf in Java or C#, you can choose a shortest in the event coc (https://www.codingame.com/events), or play with the codegolf puzzles (https://www.codingame.com/multiplayer/codegolf).

I think there are more important things like prevent system calls, or add validators to prevent hardcode.

1 Like

Excuse me if I don’t use the good words but it can go further : today you ask for the main class/function, but tomorrow someone else will ask for “system.out.println” because it’s longer than “print”, or “int.parse” longer than “+”, or “charCodeAt” longer than “[ ]” …

Languages are different, I think the only thing you need is to separate languages when you play codegolf (that’s why i put the 2 links above). And since your separate languages, you don’t need anymore to remove imports or main class.

Well, that makes sense, although the problem with playing language specific games is that it would struggle to get players and fill lobbies.

Also, for the record, I’m fine with certain languages having a disadvantage- in fact, this is a good thing, because it highlights that every language has its weaknesses and encourages someone to either learn to play around it, or to try something else. However, the problem here is that certain languages have a weakness that simply can’t be played around, and other languages have an advantage that makes them overwhelmingly dominant even without putting in the effort or knowledge. It really kills the competitive aspect, and also doesn’t feel encouraging.

On a somewhat related note, I will admit that removing imports is an incredibly dubious suggestion, since as you said, it is part of the “strategy” in the gamemode. The main reason I bring it up is because java specifically requires “java.util” for the default Scanner to take in input, and as far as I can see there isn’t a feasible alternative to this. You also can’t exactly write a shorter scanner, so there’s no strategic aspect to be gained here from the import costing characters.

A really far fetched idea would be to instead consider keywords in a language (and operation symbols like ‘+’) for the code length instead of the raw character count. These tend to be more universal, although are still not perfectly so.

But having a proper word counter will probably create a mountain of other problems and be a pain to code, so that idea likely wont work.

Oh hey, I learned something new today, haha

Instead of keywords AST tokens should be counted, with help of treesitter (Tree-sitter|Introduction). Comments and whitespaces filtered out.

Any chance we could have a setting to disable Shortest mode altogether?