Golfcoder FAQ
A code golf community leaderboard for adventofcode.com, with a focus on code size.
"Code golf is a type of recreational computer programming competition in which participants strive to achieve the shortest possible source code that solves a certain problem." [wikipedia.com]
In this challenge, short is considered has having the least amount of code tokens.
Inspired by SebLague's chess coding challenge and it's community leaderboard.
This project is not affiliated with adventofcode.com, but is a community project.
The official leaderboard calculates the score based on completion time. Depending on your personal timezone and your personal/work schedule, this can be a significant disadvantage.
I have, therefore, created this unofficial leaderboard to compare code size optimization, instead of completion time.
This leaderboard is not meant to replace the official leaderboard but to complement it with a different perspective.
I want to express my gratitude to Eric Wastl and his supporters for creating the Advent of Code challenges each year with such great detail and care!
FAQ
What is a token?
A token represents roughly one element in the
abstract syntax tree. Every name, including variables and functions, is considered as a single token, irrespective of its length. Therefore, both lines of code -
bool a = true;
and
bool aVeryDetailedVariableName = true;
- contribute equally to the token count.
Whitespaces (spaces, newlines, tabs...), statement delimiters (eg. semikolons in C++) and comments are ignored.
However, each single character in a string counts as one token, so solving the challenge with one big Regex might not be the optimal solution.
This means that the following code has a score of 13 tokens:
fun main() {
println("hi")
}
fun
main
(
)
{
println
(
"
h
i
"
)
}
How is the leaderboard sorted?
Each user has for each language one leaderboard entry. The best score from each part will be used. If a user has not submitted a solution for a part, that part will be ranked with 10_000 tokens.
Why is my language not yet supported?
Writing a tokenizer for a language is not trivial. I therefore look for a tokenizer that is already implemented and can easily be integrated. Currently all languages Golfcoder supports are tokenized with
tree-sitter.
Join the discussion on
GitHub and help to add support for your favorite language, or just upvote the language you want to promote! Please be patient, I will add more popular languages as soon as possible.
Which libraries are allowed?
Golfcoder uses
OneCompiler to execute your code (except for Kotlin, there it uses
Kotlin Playground). Please check out their site and see, if they have a "Supported libraries" section for your programming language. The standard library of your language is always supported.
My code doesn't compile or returns a wrong output in Golfcoder, but works on my machine.
Please make sure your code runs on
OneCompiler (or for Kotlin the
Kotlin Playground), which Golfcoder uses as code execution infrastructure.
I found a bug/hack in the tokenization.
Please report it on
GitHub, so I can fix it. You might also try to fix it yourself, check out the
GitHub repository on how to run Golfcoder locally. After fixing it, I will re-analyze all solutions to make sure the leaderboard is fair.
Credits