Skip to content

rlopzc/protohackers_zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Protohackers in Zig

I'm solving the protohackers in Zig to learn more about networking and continue learning Zig.

Each problem has it's corresponding file in src, e.g. src/01_smoke_test.zig. The common logic is extracted in different files, e.g. src/tcp_server.zig.

I used CLI arguments to run a specific problem. To run the smoke test, run:

# Smoke test
zig build run -- 00

# Prime time
zig build run -- 01

Docker

I dockerized this project to be run in any server. The images are exposed in Github Container Registry here.

Building the images:

docker buildx build --platform linux/arm64,linux/amd64 -t ghcr.io/rlopzc/protohackers_zig:latest --push .

Running the image in any cloud provider

  1. Create a server in a cloud provider (I used Hetzner)

  2. Pull the image. You can either pull the latest, which should contain most solutions, or a specific tag with a solution.

    docker pull ghcr.io/rlopzc/protohackers_zig:0_smoke
    # or
    docker pull ghcr.io/rlopzc/protohackers_zig:latest
  3. Run the image. Remember to pass the problem number as an argument.

    docker run --rm --name protohackers_zig -p 3000:3000 --init ghcr.io/rlopzc/protohackers_zig:latest 00
  4. Run the protohacker test using their website!

About

Solving protohackers.com problems with Zig

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages