Golf coding
2024, Jul 07 edited
The Coding Golf competitions are basically coding challenges, where the aim is to provide a solution to a coding problem while minimizing the number of characters. It targets the ability of the competitors to find tricks that reduce the size of the code, without losing it effectiveness. Hence the name of this challenge, coding golf as similarly to the sport, the aim is to achieve the target in the minimum number of shots.
On websites like Codingame it's possible to solve Coding Golf puzzles in the "Taille de Code" section. In this version of the competition, the coder is presented a coding puzzle, then it must then select a coding language. Now it can start building its coding solution for this puzzle. Once a solution is ready, the competitor can submit its solution via the website interface.
The correctness of the code is then verified, after the submission, as the proposed code is tested against a certain number of test cases. Once the code achieves 100% of correctness on the validation cases, the competitor can enter the leader board of the challenge, by submitting again its code. The code is once again checked against a test set of cases and if validated, the submission of the user in entered in the leader board.
It’s then possible to search for a better (smaller) solution and submit it again. Each time the new proposed code must be tested against the validation and the test cases.
As the size of the answer can be dependent on the language used it's possible to submit answers written in different languages. A leader board allows measuring each combination competitor and language performance as well as finding the best results for each language. Indeed the ranking can be different as even if using the same logic, the solution in JavaScript will probably have a different size compared to the one written in Python.
For illustration, you'll find below a few examples of python coding tricks that can be pretty useful in Code Golf challenges.
On websites like Codingame it's possible to solve Coding Golf puzzles in the "Taille de Code" section. In this version of the competition, the coder is presented a coding puzzle, then it must then select a coding language. Now it can start building its coding solution for this puzzle. Once a solution is ready, the competitor can submit its solution via the website interface.
The correctness of the code is then verified, after the submission, as the proposed code is tested against a certain number of test cases. Once the code achieves 100% of correctness on the validation cases, the competitor can enter the leader board of the challenge, by submitting again its code. The code is once again checked against a test set of cases and if validated, the submission of the user in entered in the leader board.
It’s then possible to search for a better (smaller) solution and submit it again. Each time the new proposed code must be tested against the validation and the test cases.
As the size of the answer can be dependent on the language used it's possible to submit answers written in different languages. A leader board allows measuring each combination competitor and language performance as well as finding the best results for each language. Indeed the ranking can be different as even if using the same logic, the solution in JavaScript will probably have a different size compared to the one written in Python.
For illustration, you'll find below a few examples of python coding tricks that can be pretty useful in Code Golf challenges.


