Skip to content

Instantly share code, notes, and snippets.

Last active December 25, 2020 08:02
Show Gist options
  • Save williewillus/07f534b706262ccc67119ddc70b2bd75 to your computer and use it in GitHub Desktop.
Save williewillus/07f534b706262ccc67119ddc70b2bd75 to your computer and use it in GitHub Desktop.
Advent of Code in C - Challenge Guidelines

Want to do Advent of Code in pure C? Let's do 2020's series together.


Join my leaderboard: 21245-df3e4d76


Why not?

C Standard and Platform

  • 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)

Build System

  • 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

  • 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)

Example Setup

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:

Copy link


Copy link


Copy link

eutro commented Nov 28, 2020


Copy link

Alwinfy commented Dec 1, 2020

heck yeah

Copy link

Vazkii commented Dec 2, 2020


Copy link

PCRE? SSL? do it in POSIX.

Copy link

I actually haven't had a need to use either yet.

Copy link

I expected to need PCRE for 19.2, did you use POSIX regex or roll your own pseduoregex?

Copy link

I used the CYK algorithm to recognize strings. It's super slow but it works.

Copy link

Great job everyone on this years advent of code! Merry Christmas :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment