Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rlopzc/protohackers_zig
Solving protohackers.com problems with Zig
https://github.com/rlopzc/protohackers_zig
networking protohackers zig ziglang
Last synced: 8 days ago
JSON representation
Solving protohackers.com problems with Zig
- Host: GitHub
- URL: https://github.com/rlopzc/protohackers_zig
- Owner: rlopzc
- Created: 2024-10-15T00:53:41.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-12-31T14:33:03.000Z (about 1 month ago)
- Last Synced: 2025-01-29T04:34:10.503Z (13 days ago)
- Topics: networking, protohackers, zig, ziglang
- Language: Zig
- Homepage:
- Size: 190 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Protohackers in Zig
I'm solving the [protohackers](https://protohackers.com/) 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:
```sh
# 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](https://github.com/rlopzc/protohackers_zig/pkgs/container/protohackers_zig).Building the images:
```sh
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)
1. Pull the image. You can either pull the latest, which should contain most solutions, or a specific tag with a
solution.
```sh
docker pull ghcr.io/rlopzc/protohackers_zig:0_smoke
# or
docker pull ghcr.io/rlopzc/protohackers_zig:latest
```1. Run the image. Remember to pass the problem number as an argument.
```sh
docker run --rm --name protohackers_zig -p 3000:3000 --init ghcr.io/rlopzc/protohackers_zig:latest 00
```
1. Run the protohacker test using their website!