Skip to content

A simple template to participate in the advent of code using the zig programming language.

Notifications You must be signed in to change notification settings

spanzeri/aoc-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AOC-ZIG - Readme

🎄 Project

aoc-zig is a simple template for advent of code using the zig language.

It's almost entirely unopinionated and does not provide any code for solving exercises. It simply removes some of the cruft around setting up the project so you can jump in the meat of the problems without wasting time.

The build system takes care of creating source and input files for you.

🗒️Basic usage

Clone or download the repository in a directory of your choice.

git clone https://github.com/spanzeri/aoc-zig.git

Enter the project directory (where build.zig) is located and start day one with:

zig build

The build command generates two new files for you (xx is the day number, from 1 to 25):

  • src/dayxx.zig: the source file for the day
  • src/data/inputxx.txt: the text file to copy your problem input into;

The source file (src/dayxx.zig) contains two stub functions for you to fill out.

pub fn solution1() {}
pub fn solution2() {}

If you want to start a different day, you can add -Dday to your zig build command

zig build -Dday=12

The build system remebers the last day selected, so after the intial command you can simply use: zig build or zig build run.

⚙️ Advanced usage

The build system relies on two source files:

  • templates/main.zig
  • templates/day.zig

The first source file contains the entry point that is shared for every day and there shouldn't be any need to change it.

day.zig contains the template for generating a src/dayxx.zig file.

If you'd like to change the default template file, you can do it there (e.g. to add some shared util includes).

The template supports some simple variable substitution on generation.

Currently it supports: ${day} which gets converted to the corresponding day number.

To add more variables, see create_day_source_from_code in build.zig.

❤️ Contributing

This is a very simple template and should probably remain as simple as possible.

Feel free to fork and change it to your liking.

It was also put together in a few hours while learning the language and build system.

If you spot any obvious mistake feel free to let me know.

🪪 License

This software is available under 2 licenses - choose whichever one you prefer.

Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A simple template to participate in the advent of code using the zig programming language.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages