Compare commits
No commits in common. "7ac9a5289289da1cd22462734ec0a03af97b6be8" and "9b70de21c7c0aa0e3db86d87c3169fb1769efeba" have entirely different histories.
7ac9a52892
...
9b70de21c7
37 changed files with 430 additions and 21791 deletions
2
.vscode/extensions.json
vendored
2
.vscode/extensions.json
vendored
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"recommendations": [
|
||||
"ziglang.vscode-zig",
|
||||
"augusterame.zls-vscode",
|
||||
"ms-vscode.cpptools"
|
||||
]
|
||||
}
|
||||
|
|
50
.vscode/tasks.json
vendored
50
.vscode/tasks.json
vendored
|
@ -7,7 +7,7 @@
|
|||
"label": "build day 01",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day01"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day01"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -15,7 +15,7 @@
|
|||
"label": "build day 02",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day02"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day02"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -23,7 +23,7 @@
|
|||
"label": "build day 03",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day03"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day03"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -31,7 +31,7 @@
|
|||
"label": "build day 04",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day04"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day04"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -39,7 +39,7 @@
|
|||
"label": "build day 05",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day05"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day05"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -47,7 +47,7 @@
|
|||
"label": "build day 06",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day06"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day06"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -55,7 +55,7 @@
|
|||
"label": "build day 07",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day07"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day07"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -63,7 +63,7 @@
|
|||
"label": "build day 08",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day08"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day08"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -71,7 +71,7 @@
|
|||
"label": "build day 09",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day09"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day09"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -79,7 +79,7 @@
|
|||
"label": "build day 10",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day10"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day10"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -87,7 +87,7 @@
|
|||
"label": "build day 11",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day11"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day11"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -95,7 +95,7 @@
|
|||
"label": "build day 12",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day12"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day12"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -103,7 +103,7 @@
|
|||
"label": "build day 13",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day13"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day13"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -111,7 +111,7 @@
|
|||
"label": "build day 14",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day14"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day14"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -119,7 +119,7 @@
|
|||
"label": "build day 15",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day15"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day15"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -127,7 +127,7 @@
|
|||
"label": "build day 16",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day16"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day16"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -135,7 +135,7 @@
|
|||
"label": "build day 17",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day17"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day17"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -143,7 +143,7 @@
|
|||
"label": "build day 18",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day18"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day18"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -151,7 +151,7 @@
|
|||
"label": "build day 19",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day19"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day19"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -159,7 +159,7 @@
|
|||
"label": "build day 20",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day20"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day20"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -167,7 +167,7 @@
|
|||
"label": "build day 21",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day21"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day21"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -175,7 +175,7 @@
|
|||
"label": "build day 22",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day22"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day22"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -183,7 +183,7 @@
|
|||
"label": "build day 23",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day23"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day23"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -191,7 +191,7 @@
|
|||
"label": "build day 24",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day24"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day24"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
@ -199,7 +199,7 @@
|
|||
"label": "build day 25",
|
||||
"type": "shell",
|
||||
"command": "zig",
|
||||
"args": ["build", "install_day25"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
|
||||
"args": ["build", "install_day25"], // add -Drelease-safe=true or -Drelease-fast=true to optimize
|
||||
"problemMatcher": [],
|
||||
"group": "build",
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
This repo provides a template for Advent of Code participants using Zig. It contains a main file for each day, a build.zig file set up with targets for each day, and Visual Studio Code files for debugging.
|
||||
|
||||
This template has been tested with Zig `0.12.0-dev.1754+2a3226453`. It may not work with other versions.
|
||||
This template has been tested with Zig 0.10.0. It may not work with other versions.
|
||||
|
||||
## How to use this template:
|
||||
|
||||
|
@ -10,9 +10,9 @@ The src/ directory contains a main file for each day. Put your code there. The
|
|||
|
||||
Each day contains a decl like this:
|
||||
```zig
|
||||
const data = @embedFile("data/day05.txt");
|
||||
const data = @embedFile("../data/day05.txt");
|
||||
```
|
||||
To use this system, save your input for a day in the src/data/ directory with the appropriate name. Reference this decl to load the contents of that file as a compile time constant. If a day has no input, or you prefer not to embed it in this form, simply don't reference this decl. If `data` is unused, the compiler will not try to load the file, and it won't error if the file does not exist.
|
||||
To use this system, save your input for a day in the data/ directory with the appropriate name. Reference this decl to load the contents of that file as a compile time constant. If a day has no input, or you prefer not to embed it in this form, simply don't reference this decl. If `data` is unused, the compiler will not try to load the file, and it won't error if the file does not exist.
|
||||
|
||||
This repo also contains Visual Studio Code project files for debugging. These are meant to work with the C/C++ plugin. There is a debug configuration for each day. By default all days are built in debug mode, but this can be changed by editing `.vscode/tasks.json` if you have a need for speed.
|
||||
|
||||
|
|
135
build.zig
135
build.zig
|
@ -1,40 +1,52 @@
|
|||
const std = @import("std");
|
||||
const Build = std.Build;
|
||||
const CompileStep = std.Build.Step.Compile;
|
||||
const Builder = std.build.Builder;
|
||||
const LibExeObjStep = std.build.LibExeObjStep;
|
||||
|
||||
/// set this to true to link libc
|
||||
// set this to true to link libc
|
||||
const should_link_libc = false;
|
||||
|
||||
const required_zig_version = std.SemanticVersion.parse("0.12.0-dev.1754+2a3226453") catch unreachable;
|
||||
|
||||
fn linkObject(b: *Build, obj: *CompileStep) void {
|
||||
fn linkObject(b: *Builder, obj: *LibExeObjStep) void {
|
||||
if (should_link_libc) obj.linkLibC();
|
||||
_ = b;
|
||||
|
||||
// Add linking for packages or third party libraries here
|
||||
}
|
||||
|
||||
pub fn build(b: *Build) void {
|
||||
const required_zig_version = std.SemanticVersion.parse("0.10.0") catch unreachable;
|
||||
const padded_int_fix = std.SemanticVersion.parse("0.11.0-dev.331+304e82808") catch unreachable;
|
||||
|
||||
pub fn build(b: *Builder) void {
|
||||
if (comptime @import("builtin").zig_version.order(required_zig_version) == .lt) {
|
||||
std.debug.print("Warning: Your version of Zig too old. You will need to download a newer build\n", .{});
|
||||
std.debug.print(
|
||||
\\Error: Your version of Zig is missing features that are needed for this template.
|
||||
\\You will need to download a newer build.
|
||||
\\
|
||||
\\ https://ziglang.org/download/
|
||||
\\
|
||||
\\
|
||||
, .{});
|
||||
std.os.exit(1);
|
||||
}
|
||||
|
||||
// Standard target options allows the person running `zig build` to choose
|
||||
// what target to build for. Here we do not override the defaults, which
|
||||
// means any target is allowed, and the default is native. Other options
|
||||
// for restricting supported target set are available.
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const mode = b.standardOptimizeOption(.{});
|
||||
|
||||
// Standard release options allow the person running `zig build` to select
|
||||
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
||||
const mode = b.standardReleaseOptions();
|
||||
|
||||
const install_all = b.step("install_all", "Install all days");
|
||||
const install_all_tests = b.step("install_tests_all", "Install tests for all days");
|
||||
const run_all = b.step("run_all", "Run all days");
|
||||
|
||||
const generate = b.step("generate", "Generate stub files from template/template.zig");
|
||||
const build_generate = b.addExecutable(.{
|
||||
.name = "generate",
|
||||
.root_source_file = .{ .path = "template/generate.zig" },
|
||||
.optimize = .ReleaseSafe,
|
||||
});
|
||||
|
||||
const run_generate = b.addRunArtifact(build_generate);
|
||||
run_generate.setCwd(.{ .path = std.fs.path.dirname(@src().file).? });
|
||||
const build_generate = b.addExecutable("generate", "template/generate.zig");
|
||||
build_generate.setBuildMode(.ReleaseSafe);
|
||||
const run_generate = build_generate.run();
|
||||
run_generate.cwd = std.fs.path.dirname(@src().file).?;
|
||||
generate.dependOn(&run_generate.step);
|
||||
|
||||
// Set up an exe for each day
|
||||
|
@ -43,24 +55,34 @@ pub fn build(b: *Build) void {
|
|||
const dayString = b.fmt("day{:0>2}", .{day});
|
||||
const zigFile = b.fmt("src/{s}.zig", .{dayString});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = dayString,
|
||||
.root_source_file = .{ .path = zigFile },
|
||||
.target = target,
|
||||
.optimize = mode,
|
||||
});
|
||||
const exe = b.addExecutable(dayString, zigFile);
|
||||
exe.setTarget(target);
|
||||
exe.setBuildMode(mode);
|
||||
linkObject(b, exe);
|
||||
|
||||
const install_cmd = b.addInstallArtifact(exe, .{});
|
||||
// Padded integers are buggy in 0.10.0, fixed in 0.11.0-dev.331+304e82808
|
||||
// This is especially bad for AoC because std.StaticBitSet is commonly used.
|
||||
// If your version is older than that, we use stage1 to avoid this bug.
|
||||
// Issue: https://github.com/ziglang/zig/issues/13480
|
||||
// Fix: https://github.com/ziglang/zig/pull/13637
|
||||
if (comptime @import("builtin").zig_version.order(padded_int_fix) == .lt) {
|
||||
exe.use_stage1 = true;
|
||||
}
|
||||
|
||||
const build_test = b.addTest(.{
|
||||
.root_source_file = .{ .path = zigFile },
|
||||
.target = target,
|
||||
.optimize = mode,
|
||||
});
|
||||
linkObject(b, build_test);
|
||||
exe.install();
|
||||
|
||||
const run_test = b.addRunArtifact(build_test);
|
||||
const install_cmd = b.addInstallArtifact(exe);
|
||||
|
||||
const run_test = b.addTest(zigFile);
|
||||
run_test.setTarget(target);
|
||||
run_test.setBuildMode(mode);
|
||||
linkObject(b, exe);
|
||||
|
||||
const build_test = b.addTestExe(b.fmt("test_{s}", .{dayString}), zigFile);
|
||||
build_test.setTarget(target);
|
||||
build_test.setBuildMode(mode);
|
||||
linkObject(b, exe);
|
||||
const install_test = b.addInstallArtifact(build_test);
|
||||
|
||||
{
|
||||
const step_key = b.fmt("install_{s}", .{dayString});
|
||||
|
@ -77,7 +99,16 @@ pub fn build(b: *Build) void {
|
|||
step.dependOn(&run_test.step);
|
||||
}
|
||||
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
{
|
||||
const step_key = b.fmt("install_tests_{s}", .{dayString});
|
||||
const step_desc = b.fmt("Install test_{s}.exe", .{dayString});
|
||||
const step = b.step(step_key, step_desc);
|
||||
step.dependOn(&install_test.step);
|
||||
install_all_tests.dependOn(&install_test.step);
|
||||
}
|
||||
|
||||
const run_cmd = exe.run();
|
||||
run_cmd.step.dependOn(&install_cmd.step);
|
||||
if (b.args) |args| {
|
||||
run_cmd.addArgs(args);
|
||||
}
|
||||
|
@ -91,12 +122,42 @@ pub fn build(b: *Build) void {
|
|||
// Set up tests for util.zig
|
||||
{
|
||||
const test_util = b.step("test_util", "Run tests in util.zig");
|
||||
const test_cmd = b.addTest(.{
|
||||
.root_source_file = .{ .path = "src/util.zig" },
|
||||
.target = target,
|
||||
.optimize = mode,
|
||||
});
|
||||
const test_cmd = b.addTest("src/util.zig");
|
||||
test_cmd.setTarget(target);
|
||||
test_cmd.setBuildMode(mode);
|
||||
linkObject(b, test_cmd);
|
||||
test_util.dependOn(&test_cmd.step);
|
||||
}
|
||||
|
||||
// Set up test executable for util.zig
|
||||
{
|
||||
const test_util = b.step("install_tests_util", "Run tests in util.zig");
|
||||
const test_exe = b.addTestExe("test_util", "src/util.zig");
|
||||
test_exe.setTarget(target);
|
||||
test_exe.setBuildMode(mode);
|
||||
linkObject(b, test_exe);
|
||||
const install = b.addInstallArtifact(test_exe);
|
||||
test_util.dependOn(&install.step);
|
||||
}
|
||||
|
||||
// Set up a step to run all tests
|
||||
{
|
||||
const test_step = b.step("test", "Run all tests");
|
||||
const test_cmd = b.addTest("src/test_all.zig");
|
||||
test_cmd.setTarget(target);
|
||||
test_cmd.setBuildMode(mode);
|
||||
linkObject(b, test_cmd);
|
||||
test_step.dependOn(&test_cmd.step);
|
||||
}
|
||||
|
||||
// Set up a step to build tests (but not run them)
|
||||
{
|
||||
const test_build = b.step("install_tests", "Install test_all.exe");
|
||||
const test_exe = b.addTestExe("test_all", "src/test_all.zig");
|
||||
test_exe.setTarget(target);
|
||||
test_exe.setBuildMode(mode);
|
||||
linkObject(b, test_exe);
|
||||
const test_exe_install = b.addInstallArtifact(test_exe);
|
||||
test_build.dependOn(&test_exe_install.step);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
.{
|
||||
.name = "Zig-AoC-Template",
|
||||
.version = "0.12.0-dev",
|
||||
.dependencies = .{},
|
||||
.paths = .{""},
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
two1nine
|
||||
eightwothree
|
||||
abcone2threexyz
|
||||
xtwone3four
|
||||
4nineeightseven2
|
||||
zoneight234
|
||||
7pqrstsixteen
|
||||
|
1000
src/data/day01.txt
1000
src/data/day01.txt
File diff suppressed because it is too large
Load diff
190
src/day01.zig
190
src/day01.zig
|
@ -8,194 +8,15 @@ const BitSet = std.DynamicBitSet;
|
|||
const util = @import("util.zig");
|
||||
const gpa = util.gpa;
|
||||
|
||||
// const data = @embedFile("data/day01.test.txt");
|
||||
const data = @embedFile("data/day01.txt");
|
||||
const data2 = @embedFile("data/day01_part2.txt");
|
||||
|
||||
pub fn main() !void {
|
||||
const allocator = std.heap.page_allocator;
|
||||
|
||||
const part01_total = try part01(allocator, data);
|
||||
const part02_total = try part02(allocator, data);
|
||||
|
||||
std.debug.print("Part01: {d}\n", .{part01_total});
|
||||
std.debug.print("Part02: {d}\n", .{part02_total});
|
||||
}
|
||||
|
||||
fn find_first_digit_number(word: []const u8) !u8 {
|
||||
var i: usize = 0;
|
||||
|
||||
while (i < word.len) : (i += 1) {
|
||||
if (std.ascii.isDigit(word[i])) {
|
||||
return word[i];
|
||||
}
|
||||
}
|
||||
|
||||
return '0';
|
||||
}
|
||||
|
||||
fn find_first_digit_number_or_string(word: []const u8) !u32 {
|
||||
const numbers = [_][]const u8{ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
|
||||
|
||||
var digit: u32 = 0;
|
||||
|
||||
var i: usize = 0;
|
||||
var digit_i: usize = 10;
|
||||
|
||||
while (i < word.len) : (i += 1) {
|
||||
if (std.ascii.isDigit(word[i])) {
|
||||
digit = try std.fmt.charToDigit(word[i], 10);
|
||||
digit_i = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (numbers, 0..) |n, j| {
|
||||
const index = std.mem.indexOf(u8, word, n) orelse word.len;
|
||||
if (index < digit_i) {
|
||||
digit_i = index;
|
||||
digit = @intCast(j);
|
||||
}
|
||||
}
|
||||
|
||||
return digit;
|
||||
}
|
||||
|
||||
fn find_last_digit_number_or_string(word: []const u8) !u32 {
|
||||
const numbers = [_][]const u8{ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
|
||||
|
||||
var digit: u32 = 0;
|
||||
|
||||
var i: usize = word.len - 1;
|
||||
var digit_i: usize = word.len;
|
||||
|
||||
while (i >= 0) : (i -= 1) {
|
||||
// std.debug.print("word[{d}]={c}\n", .{ i, word[i] });
|
||||
if (std.ascii.isDigit(word[i])) {
|
||||
digit = try std.fmt.charToDigit(word[i], 10);
|
||||
digit_i = i;
|
||||
break;
|
||||
}
|
||||
if (i == 0) {
|
||||
digit_i = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (numbers, 0..) |n, j| {
|
||||
// std.debug.print("checking for word {s}\n", .{n});
|
||||
const index = std.mem.lastIndexOf(u8, word, n) orelse 0;
|
||||
if (index > digit_i) {
|
||||
digit_i = index;
|
||||
// std.debug.print("found word {s} {d}\n", .{ n, index });
|
||||
digit = @intCast(j);
|
||||
}
|
||||
}
|
||||
|
||||
return digit;
|
||||
}
|
||||
fn find_last_digit_number(word: []const u8) !u8 {
|
||||
var i: usize = word.len - 1;
|
||||
while (i >= 0) : (i -= 1) {
|
||||
if (std.ascii.isDigit(word[i])) {
|
||||
// std.debug.print("last {c}\n", .{word[i]});
|
||||
return word[i];
|
||||
}
|
||||
}
|
||||
|
||||
return '0';
|
||||
}
|
||||
|
||||
test "validate part01" {
|
||||
const test_data =
|
||||
\\1abc2
|
||||
\\pqr3stu8vwx
|
||||
\\a1b2c3d4e5f
|
||||
\\treb7uchet
|
||||
;
|
||||
|
||||
const expectedValue: u32 = 142;
|
||||
const part01_total = try part01(std.testing.allocator, test_data);
|
||||
|
||||
try std.testing.expectEqual(expectedValue, part01_total);
|
||||
}
|
||||
|
||||
test "validate part02" {
|
||||
const test_data =
|
||||
\\two1nine
|
||||
\\eightwothree
|
||||
\\abcone2threexyz
|
||||
\\xtwone3four
|
||||
\\4nineeightseven2
|
||||
\\zoneight234
|
||||
\\oneeighttwo34dcjck5eightjznpzhxdlc
|
||||
\\7pqrstsixteen
|
||||
;
|
||||
|
||||
const expected_value: u32 = 299;
|
||||
|
||||
const part02_total = try part02(std.testing.allocator, test_data);
|
||||
|
||||
try std.testing.expectEqual(expected_value, part02_total);
|
||||
}
|
||||
|
||||
fn part01(allocator: std.mem.Allocator, day01: []const u8) !u32 {
|
||||
var splits = std.mem.split(u8, day01, "\n");
|
||||
var total: u32 = 0;
|
||||
while (splits.next()) |line| {
|
||||
if (line.len <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// std.debug.print("Line: {s}\n", .{line});
|
||||
const first_digit_char = try find_first_digit_number(line);
|
||||
const last_digit_char = try find_last_digit_number(line);
|
||||
|
||||
const first_and_last = try std.fmt.allocPrint(allocator, "{c}{c}", .{ first_digit_char, last_digit_char });
|
||||
defer allocator.free(first_and_last);
|
||||
|
||||
// std.debug.print("{c} + {c}\n", .{ first_digit_char, last_digit_char });
|
||||
var digits: u32 = 0;
|
||||
digits = try std.fmt.parseInt(u32, first_and_last, 10);
|
||||
total += digits;
|
||||
}
|
||||
|
||||
return total;
|
||||
// std.debug.print("First Total: {d}\n", .{total});
|
||||
}
|
||||
|
||||
fn part02(allocator: std.mem.Allocator, day01: []const u8) !u32 {
|
||||
var splits = std.mem.split(u8, day01, "\n");
|
||||
var total: u32 = 0;
|
||||
while (splits.next()) |line| {
|
||||
if (line.len <= 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// std.debug.print("line: {s}\n", .{line});
|
||||
const first_digit_char = try find_first_digit_number_or_string(line);
|
||||
const last_digit_char = try find_last_digit_number_or_string(line);
|
||||
|
||||
const first_and_last = try std.fmt.allocPrint(allocator, "{d}{d}", .{ first_digit_char, last_digit_char });
|
||||
defer allocator.free(first_and_last);
|
||||
|
||||
// std.debug.print("{d} + {d}\n", .{ first_digit_char, last_digit_char });
|
||||
var digits: u32 = 0;
|
||||
digits = try std.fmt.parseInt(u32, first_and_last, 10);
|
||||
// std.debug.print("{d} + {d}\n", .{ total, digits });
|
||||
total += digits;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -209,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day02.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day03.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day04.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day05.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day06.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day07.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day08.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day09.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day10.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day11.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day12.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day13.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day14.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day15.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day16.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day17.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day18.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day19.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day20.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day21.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day22.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day23.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day24.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day25.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
16
src/util.zig
16
src/util.zig
|
@ -11,13 +11,10 @@ pub const gpa = gpa_impl.allocator();
|
|||
|
||||
// Add utility functions here
|
||||
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -31,9 +28,14 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
|
|
@ -31,7 +31,7 @@ fn readHashes() !*[25][Hash.digest_length]u8 {
|
|||
if (hash_bytes.len != 25 * Hash.digest_length)
|
||||
return error.InvalidFormat;
|
||||
|
||||
return @ptrCast(hash_bytes.ptr);
|
||||
return @ptrCast(*[25][Hash.digest_length]u8, hash_bytes.ptr);
|
||||
}
|
||||
|
||||
pub fn main() !void {
|
||||
|
@ -41,7 +41,7 @@ pub fn main() !void {
|
|||
error.FileNotFound => blk: {
|
||||
std.debug.print("{s} doesn't exist, will assume all files have been modified.\nDelete src/dayXX.zig and rerun `zig build generate` to regenerate it.\n", .{hashes_file});
|
||||
const mem = try gpa.allocator().create([25][Hash.digest_length]u8);
|
||||
@memset(std.mem.sliceAsBytes(mem), 0);
|
||||
@memset(@ptrCast([*]u8, mem), 0, @sizeOf(@TypeOf(mem.*)));
|
||||
break :blk mem;
|
||||
},
|
||||
error.InvalidFormat => {
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
Ř»ËÍoűö(“Ŕ<E2809C>aSôÚŞx0QoÔɉjU!@Ĺh@GU•/Ř ,–Ő ŹSźs<C5BA><73>N´<4E>(a Jq‘;żŃĹB<C4B9>}Ăö÷˘fŠäGQĄÜ[Üç¶ó&Ě•« ě ôf a×Mtâ<10>‡=ęĐ2ć]vś źú|PŐ >™ÚDŚ>=Wq[ż¤Ď´P’ÉZvorrRur[J|ŇW¸)Âc^–ŹbŘđ!ë±Z]ĄŁ›sж߾!˛n'°Q{÷&JqóbA…˛ŕČŇ `ąHü<48>’pňIĂúŕ<C3BA>©«Îkë›X`+LÎŇuBź}„š¤7Ũ»ęµő521éJáŘ
|
||||
¨ KłîߤŽJ]Ě/·%<25>YXat”šCˇĆŢć3AK¬†T¬’Ť—‹šzüňTşŔ5G©H]©ŚLËćţňó<ę}×(Ü`Ë̇&oŽ<đ±Aţ]6î:˘a‡E†ní|Eş`°Ó™LÜ•,‡ÇŞřďd%î¸'',pÇ:ń
|
||||
*®3tïgº°iŽô™Q[ûå/ÖX°ÿÕå1¯äcT—7È£Cžd`´¬'µsÓR&=ÈR/º^Ä<>|€h—Jà—Ü{-†d{¼Œ|ㆾîþï4™ú„ƒª^¿üdz·C²Êõ)¸Ù”³=‘ÒÏì¬,…¥ƒ§Iã<49>œO|„Á\SŸïŧê!V£7äï3ÃZ¢# @GX°ö”‘ÈØ<C388>T¬#Ìhb3Œâ¢Yì*aí±ðû1—»¾ExåýáÑ)×Seì<65>î-é>;„ÉõqhvÈCL·üµ;«õ’¸‹5â+X©I_àfð,\…Ñ—îL>o›ûõl€×vÇnCÈ7jö‹Ý V¯›|¹Ð4ŽRÍ7L‘ì–<C3AC>·iCqóÙ [ž
ë¤&\ˆlùÀ»«=ÌÇÇ“œë>&4ÔRERhX;"Ì3Çk}=Ó±žQÈú”OrZFÚìg ¹VâÑ•y‹À¸.åî!õæ‹>ø?†òÇ·‹‚hÕ=:: –”Ä
|
|
@ -10,15 +10,13 @@ const gpa = util.gpa;
|
|||
|
||||
const data = @embedFile("data/day$.txt");
|
||||
|
||||
pub fn main() !void {}
|
||||
pub fn main() !void {
|
||||
|
||||
}
|
||||
|
||||
// Useful stdlib functions
|
||||
const tokenizeAny = std.mem.tokenizeAny;
|
||||
const tokenizeSeq = std.mem.tokenizeSequence;
|
||||
const tokenizeSca = std.mem.tokenizeScalar;
|
||||
const splitAny = std.mem.splitAny;
|
||||
const splitSeq = std.mem.splitSequence;
|
||||
const splitSca = std.mem.splitScalar;
|
||||
const tokenize = std.mem.tokenize;
|
||||
const split = std.mem.split;
|
||||
const indexOf = std.mem.indexOfScalar;
|
||||
const indexOfAny = std.mem.indexOfAny;
|
||||
const indexOfStr = std.mem.indexOfPosLinear;
|
||||
|
@ -32,10 +30,15 @@ const sliceMax = std.mem.max;
|
|||
const parseInt = std.fmt.parseInt;
|
||||
const parseFloat = std.fmt.parseFloat;
|
||||
|
||||
const min = std.math.min;
|
||||
const min3 = std.math.min3;
|
||||
const max = std.math.max;
|
||||
const max3 = std.math.max3;
|
||||
|
||||
const print = std.debug.print;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const sort = std.sort.block;
|
||||
const sort = std.sort.sort;
|
||||
const asc = std.sort.asc;
|
||||
const desc = std.sort.desc;
|
||||
|
||||
|
|
Loading…
Reference in a new issue