Want to do Advent of Code in pure C? Let's do 2020's series together.
Join my leaderboard: 21245-df3e4d76
Why not?
- You may use any released standard of the C language (C89, C99, C11, C18).
- We will use the x86_64 architecture, and inline asm is allowed.
Approved list of libraries. Only these are allowed:
- your platform libc and any auxiliary libraries that ship with the base system (e.g. libraries to implement POSIX functions, etc.). See below for portability notes. Docs: Your system's man pages. OpenBSD man pages also sometimes contain helpful examples of usage, even if there are minor variations from Linux
- PCRE/PCRE2 (for regular expressions). Doc. Note that POSIX has some limited regex support that might be easier to use, if you don't need advanced features. See regex(7).
- OpenSSL/LibreSSL (for cryptographic hash functions AoC commonly uses such as SHA or MD5).
- uthash (for general useful data structures). Doc
- json-c, jansson, or similar library (for json parsing, if a problem requires it)
- You may use any build system of your choosing. Common choices: Makefile, Meson, CMake
- You may also make your users build by hand like cowboys, but that's poor form.
- For any one day, you may use another language besides C for both parts of the problem. This lifeline cannot be split and used on two parts of two separate days - you must use it only on one day. Use it wisely.
- Bonus points if your solution (incl. build system) is portable and builds + runs correctly on Linux and at least one other BSD (with the platform compiler). This means sticking mostly to POSIX and not using extensions unless they're present on both systems. Be careful that any inline ASM you use is portable.
- Bonus points for especially efficient solutions (evaluation criteria TBD)
I've prepared a Meson project with some sample code using openssl and uthash, feel free to use it as a starting point. It builds and runs on both Linux and OpenBSD: https://git.sr.ht/~williewillus/aoc_2020/tree/469dd810455b7af135dcc2cc088f444b23f6f202
I actually haven't had a need to use either yet.