GithubHelp home page GithubHelp logo

adventofcode-2023's Introduction

Advent Of Code 2023

Advent Of Code 2023 Solutions in Zig (version 0.11.0)

Basic Usage

The template folder contains, obviously, the template for a single day's problems. The create_day script will conveniently copy-paste the template to a new day for you, including changing the output binary name to match the day.

For example: create_day 5 creates a folder named 5 which contains a Zig project setup to build a day5 binary.

Using the templates

Each day is a standalone Zig project, containing a build.zig file, a main.zig file, and .txt files for the problem input. The test.txt file is intended for the sample input, while the input.txt file is intended for your unique input.

Within main.zig there are placeholder functions for part1 and part2, and a main() which runs both parts (and helpfully times them for you). There are also two tests, one for each part; you can use these to check your solution against the sample input and solution given in the problem statements. Just change the line const answer: usize = 0; to the expected answer.

The template also creates a utils module from the common folder in the root; this can be used to store generically useful algorithms and data structures to speed up your problem solving. The template main.zig file imports this module as utils.

Build & Run

./create_day 5
cd 5
zig build test # Build and run the tests
zig build run  # Build and run main()

Sample output for unit tests:

AdventOfCode2023/5$ zig build test --summary all
run test: error: [aoc] (warn): -- Running Tests --
[aoc] (warn): [Test] Part 1: 0
[aoc] (warn): [Test] Part 2: 0
Build Summary: 3/3 steps succeeded; 2/2 tests passed
test success
└─ run test 2 passed 829us MaxRSS:1M
   └─ zig test Debug native cached 5ms MaxRSS:36M

Sample output for for the full input:

AdventOfCode2023/5$ zig build run
info(aoc): Part 1 answer: << 0 >>
info(aoc): Part 1 took 0.000010s
info(aoc): Part 2 answer: << 0 >>
info(aoc): Part 2 took 0.000004s

adventofcode-2023's People

Contributors

jacobcrabill avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.