Compare commits

...

10 commits

Author SHA1 Message Date
7ac9a52892
chore: Remove unused function for day1 2023-12-02 17:59:56 +01:00
25c51154bb
day 1 - Part02 2023-12-02 14:13:14 +01:00
5fad9922cf
Part01 2023-12-01 21:51:50 +01:00
Krzysztof Wolicki
1ab7b46425 Remove unused step 2023-11-29 18:19:22 +01:00
Krzysztof Wolicki
466b044bba Add required_zig_version back 2023-11-29 18:17:18 +01:00
Krzysztof Wolicki
7a693efc80 Add build.zig.zon 2023-11-29 08:21:50 +01:00
Krzysztof Wolicki
d0fdfaaca7
Update README.md 2023-11-29 07:17:54 +00:00
Krzysztof Wolicki
b1584f91a2 Update template to latest master 2023-11-29 08:14:50 +01:00
Martin Wickham
0433fdb88b
Update readme to match new data directory location 2022-11-27 23:57:37 -06:00
Martin Wickham
6ddc9f5c19 Use the same compiler stage for tests and executables 2022-11-27 17:29:47 -06:00
37 changed files with 21791 additions and 430 deletions

View file

@ -1,6 +1,6 @@
{ {
"recommendations": [ "recommendations": [
"augusterame.zls-vscode", "ziglang.vscode-zig",
"ms-vscode.cpptools" "ms-vscode.cpptools"
] ]
} }

50
.vscode/tasks.json vendored
View file

@ -7,7 +7,7 @@
"label": "build day 01", "label": "build day 01",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day01"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day01"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -15,7 +15,7 @@
"label": "build day 02", "label": "build day 02",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day02"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day02"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -23,7 +23,7 @@
"label": "build day 03", "label": "build day 03",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day03"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day03"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -31,7 +31,7 @@
"label": "build day 04", "label": "build day 04",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day04"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day04"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -39,7 +39,7 @@
"label": "build day 05", "label": "build day 05",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day05"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day05"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -47,7 +47,7 @@
"label": "build day 06", "label": "build day 06",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day06"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day06"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -55,7 +55,7 @@
"label": "build day 07", "label": "build day 07",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day07"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day07"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -63,7 +63,7 @@
"label": "build day 08", "label": "build day 08",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day08"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day08"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -71,7 +71,7 @@
"label": "build day 09", "label": "build day 09",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day09"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day09"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -79,7 +79,7 @@
"label": "build day 10", "label": "build day 10",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day10"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day10"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -87,7 +87,7 @@
"label": "build day 11", "label": "build day 11",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day11"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day11"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -95,7 +95,7 @@
"label": "build day 12", "label": "build day 12",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day12"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day12"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -103,7 +103,7 @@
"label": "build day 13", "label": "build day 13",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day13"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day13"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -111,7 +111,7 @@
"label": "build day 14", "label": "build day 14",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day14"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day14"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -119,7 +119,7 @@
"label": "build day 15", "label": "build day 15",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day15"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day15"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -127,7 +127,7 @@
"label": "build day 16", "label": "build day 16",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day16"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day16"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -135,7 +135,7 @@
"label": "build day 17", "label": "build day 17",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day17"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day17"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -143,7 +143,7 @@
"label": "build day 18", "label": "build day 18",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day18"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day18"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -151,7 +151,7 @@
"label": "build day 19", "label": "build day 19",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day19"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day19"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -159,7 +159,7 @@
"label": "build day 20", "label": "build day 20",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day20"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day20"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -167,7 +167,7 @@
"label": "build day 21", "label": "build day 21",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day21"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day21"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -175,7 +175,7 @@
"label": "build day 22", "label": "build day 22",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day22"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day22"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -183,7 +183,7 @@
"label": "build day 23", "label": "build day 23",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day23"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day23"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -191,7 +191,7 @@
"label": "build day 24", "label": "build day 24",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day24"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day24"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },
@ -199,7 +199,7 @@
"label": "build day 25", "label": "build day 25",
"type": "shell", "type": "shell",
"command": "zig", "command": "zig",
"args": ["build", "install_day25"], // add -Drelease-safe=true or -Drelease-fast=true to optimize "args": ["build", "install_day25"], // add -Doptimize=ReleaseSafe or -Doptimize=ReleaseFast to optimize
"problemMatcher": [], "problemMatcher": [],
"group": "build", "group": "build",
}, },

View file

@ -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 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.10.0. It may not work with other versions. This template has been tested with Zig `0.12.0-dev.1754+2a3226453`. It may not work with other versions.
## How to use this template: ## 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: Each day contains a decl like this:
```zig ```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 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 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.
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. 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
View file

@ -1,52 +1,40 @@
const std = @import("std"); const std = @import("std");
const Builder = std.build.Builder; const Build = std.Build;
const LibExeObjStep = std.build.LibExeObjStep; const CompileStep = std.Build.Step.Compile;
// set this to true to link libc /// set this to true to link libc
const should_link_libc = false; const should_link_libc = false;
fn linkObject(b: *Builder, obj: *LibExeObjStep) void { const required_zig_version = std.SemanticVersion.parse("0.12.0-dev.1754+2a3226453") catch unreachable;
fn linkObject(b: *Build, obj: *CompileStep) void {
if (should_link_libc) obj.linkLibC(); if (should_link_libc) obj.linkLibC();
_ = b; _ = b;
// Add linking for packages or third party libraries here // Add linking for packages or third party libraries here
} }
const required_zig_version = std.SemanticVersion.parse("0.10.0") catch unreachable; pub fn build(b: *Build) void {
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) { if (comptime @import("builtin").zig_version.order(required_zig_version) == .lt) {
std.debug.print( std.debug.print("Warning: Your version of Zig too old. You will need to download a newer build\n", .{});
\\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); 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 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 = 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 run_all = b.step("run_all", "Run all days");
const generate = b.step("generate", "Generate stub files from template/template.zig"); const generate = b.step("generate", "Generate stub files from template/template.zig");
const build_generate = b.addExecutable("generate", "template/generate.zig"); const build_generate = b.addExecutable(.{
build_generate.setBuildMode(.ReleaseSafe); .name = "generate",
const run_generate = build_generate.run(); .root_source_file = .{ .path = "template/generate.zig" },
run_generate.cwd = std.fs.path.dirname(@src().file).?; .optimize = .ReleaseSafe,
});
const run_generate = b.addRunArtifact(build_generate);
run_generate.setCwd(.{ .path = std.fs.path.dirname(@src().file).? });
generate.dependOn(&run_generate.step); generate.dependOn(&run_generate.step);
// Set up an exe for each day // Set up an exe for each day
@ -55,34 +43,24 @@ pub fn build(b: *Builder) void {
const dayString = b.fmt("day{:0>2}", .{day}); const dayString = b.fmt("day{:0>2}", .{day});
const zigFile = b.fmt("src/{s}.zig", .{dayString}); const zigFile = b.fmt("src/{s}.zig", .{dayString});
const exe = b.addExecutable(dayString, zigFile); const exe = b.addExecutable(.{
exe.setTarget(target); .name = dayString,
exe.setBuildMode(mode); .root_source_file = .{ .path = zigFile },
.target = target,
.optimize = mode,
});
linkObject(b, exe); linkObject(b, exe);
// Padded integers are buggy in 0.10.0, fixed in 0.11.0-dev.331+304e82808 const install_cmd = b.addInstallArtifact(exe, .{});
// 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;
}
exe.install(); const build_test = b.addTest(.{
.root_source_file = .{ .path = zigFile },
.target = target,
.optimize = mode,
});
linkObject(b, build_test);
const install_cmd = b.addInstallArtifact(exe); const run_test = b.addRunArtifact(build_test);
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}); const step_key = b.fmt("install_{s}", .{dayString});
@ -99,16 +77,7 @@ pub fn build(b: *Builder) void {
step.dependOn(&run_test.step); 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| { if (b.args) |args| {
run_cmd.addArgs(args); run_cmd.addArgs(args);
} }
@ -122,42 +91,12 @@ pub fn build(b: *Builder) void {
// Set up tests for util.zig // Set up tests for util.zig
{ {
const test_util = b.step("test_util", "Run tests in util.zig"); const test_util = b.step("test_util", "Run tests in util.zig");
const test_cmd = b.addTest("src/util.zig"); const test_cmd = b.addTest(.{
test_cmd.setTarget(target); .root_source_file = .{ .path = "src/util.zig" },
test_cmd.setBuildMode(mode); .target = target,
.optimize = mode,
});
linkObject(b, test_cmd); linkObject(b, test_cmd);
test_util.dependOn(&test_cmd.step); 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);
}
} }

6
build.zig.zon Normal file
View file

@ -0,0 +1,6 @@
.{
.name = "Zig-AoC-Template",
.version = "0.12.0-dev",
.dependencies = .{},
.paths = .{""},
}

20310
kaka.txt Normal file

File diff suppressed because it is too large Load diff

8
src/data/day01.test.txt Normal file
View file

@ -0,0 +1,8 @@
two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen

1000
src/data/day01.txt Normal file

File diff suppressed because it is too large Load diff

View file

@ -8,15 +8,194 @@ const BitSet = std.DynamicBitSet;
const util = @import("util.zig"); const util = @import("util.zig");
const gpa = util.gpa; const gpa = util.gpa;
// const data = @embedFile("data/day01.test.txt");
const data = @embedFile("data/day01.txt"); const data = @embedFile("data/day01.txt");
const data2 = @embedFile("data/day01_part2.txt");
pub fn main() !void { 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 // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +209,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day02.txt"); const data = @embedFile("data/day02.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day03.txt"); const data = @embedFile("data/day03.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day04.txt"); const data = @embedFile("data/day04.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day05.txt"); const data = @embedFile("data/day05.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day06.txt"); const data = @embedFile("data/day06.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day07.txt"); const data = @embedFile("data/day07.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day08.txt"); const data = @embedFile("data/day08.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day09.txt"); const data = @embedFile("data/day09.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day10.txt"); const data = @embedFile("data/day10.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day11.txt"); const data = @embedFile("data/day11.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day12.txt"); const data = @embedFile("data/day12.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day13.txt"); const data = @embedFile("data/day13.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day14.txt"); const data = @embedFile("data/day14.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day15.txt"); const data = @embedFile("data/day15.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day16.txt"); const data = @embedFile("data/day16.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day17.txt"); const data = @embedFile("data/day17.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day18.txt"); const data = @embedFile("data/day18.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day19.txt"); const data = @embedFile("data/day19.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day20.txt"); const data = @embedFile("data/day20.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day21.txt"); const data = @embedFile("data/day21.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day22.txt"); const data = @embedFile("data/day22.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day23.txt"); const data = @embedFile("data/day23.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day24.txt"); const data = @embedFile("data/day24.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day25.txt"); const data = @embedFile("data/day25.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -11,10 +11,13 @@ pub const gpa = gpa_impl.allocator();
// Add utility functions here // Add utility functions here
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -28,14 +31,9 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;

View file

@ -15,7 +15,7 @@ fn instantiateTemplate(template: []const u8, day: u32) ![]const u8 {
while (std.mem.indexOfScalar(u8, rest, '$')) |index| { while (std.mem.indexOfScalar(u8, rest, '$')) |index| {
try list.appendSlice(rest[0..index]); try list.appendSlice(rest[0..index]);
try std.fmt.format(list.writer(), "{d:0>2}", .{day}); try std.fmt.format(list.writer(), "{d:0>2}", .{day});
rest = rest[index+1..]; rest = rest[index + 1 ..];
} }
try list.appendSlice(rest); try list.appendSlice(rest);
return list.toOwnedSlice(); return list.toOwnedSlice();
@ -31,7 +31,7 @@ fn readHashes() !*[25][Hash.digest_length]u8 {
if (hash_bytes.len != 25 * Hash.digest_length) if (hash_bytes.len != 25 * Hash.digest_length)
return error.InvalidFormat; return error.InvalidFormat;
return @ptrCast(*[25][Hash.digest_length]u8, hash_bytes.ptr); return @ptrCast(hash_bytes.ptr);
} }
pub fn main() !void { pub fn main() !void {
@ -41,7 +41,7 @@ pub fn main() !void {
error.FileNotFound => blk: { 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}); 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); const mem = try gpa.allocator().create([25][Hash.digest_length]u8);
@memset(@ptrCast([*]u8, mem), 0, @sizeOf(@TypeOf(mem.*))); @memset(std.mem.sliceAsBytes(mem), 0);
break :blk mem; break :blk mem;
}, },
error.InvalidFormat => { error.InvalidFormat => {
@ -49,7 +49,7 @@ pub fn main() !void {
std.os.exit(1); std.os.exit(1);
}, },
else => |e| { else => |e| {
std.debug.print("Failed to open {s}: {}\n", .{hashes_file, e}); std.debug.print("Failed to open {s}: {}\n", .{ hashes_file, e });
return e; return e;
}, },
}; };
@ -62,7 +62,7 @@ pub fn main() !void {
defer gpa.allocator().free(filename); defer gpa.allocator().free(filename);
var new_file = false; var new_file = false;
const file = std.fs.cwd().openFile(filename, .{.mode = .read_write}) catch |err| switch (err) { const file = std.fs.cwd().openFile(filename, .{ .mode = .read_write }) catch |err| switch (err) {
error.FileNotFound => blk: { error.FileNotFound => blk: {
new_file = true; new_file = true;
break :blk try std.fs.cwd().createFile(filename, .{}); break :blk try std.fs.cwd().createFile(filename, .{});
@ -86,7 +86,7 @@ pub fn main() !void {
var hash: [Hash.digest_length]u8 = undefined; var hash: [Hash.digest_length]u8 = undefined;
Hash.hash(contents, &hash, .{}); Hash.hash(contents, &hash, .{});
regenerate = std.mem.eql(u8, &hash, &hashes[day-1]); regenerate = std.mem.eql(u8, &hash, &hashes[day - 1]);
} else { } else {
regenerate = true; regenerate = true;
} }
@ -100,7 +100,7 @@ pub fn main() !void {
const text = try instantiateTemplate(template, day); const text = try instantiateTemplate(template, day);
defer gpa.allocator().free(text); defer gpa.allocator().free(text);
Hash.hash(text, &hashes[day-1], .{}); Hash.hash(text, &hashes[day - 1], .{});
updated_hashes = true; updated_hashes = true;
try file.writeAll(text); try file.writeAll(text);
@ -118,7 +118,7 @@ pub fn main() !void {
if (updated_hashes) { if (updated_hashes) {
try std.fs.cwd().writeFile(hashes_file, std.mem.asBytes(hashes)); try std.fs.cwd().writeFile(hashes_file, std.mem.asBytes(hashes));
if (skipped_any) { if (skipped_any) {
std.debug.print("Some days were skipped. Delete them to force regeneration.\n",.{}); std.debug.print("Some days were skipped. Delete them to force regeneration.\n", .{});
} }
} else { } else {
std.debug.print("No updates made, all days were modified. Delete src/dayXX.zig to force regeneration.\n", .{}); std.debug.print("No updates made, all days were modified. Delete src/dayXX.zig to force regeneration.\n", .{});

View file

@ -1 +1,2 @@
*®3tï° ô™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ÔRE RhX;"Ì3Çk}=Ó±žQÈú”OrZFÚì ­g ¹VâÑ•yÀ¸.åî!õæ>ø?†òÇ·hÕ=:: –”Ä Ř»ËÍoűö(“Ŕ<E2809C>aSôÚŞx0QoÔɉjU!@Ĺh@GU•/Ř ,–Ő Ź Sźs<C5BA><73>N´<4E>(a JqŃĹB<C4B9>}Ăö÷˘fŠäGQĄÜ[Üç¶ó&Ě•« ě ôf a×M<10>‡=ęĐ2ć]vś źú|­ >™Ú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¬†ŤšzüňTşŔ5G©H]©ŚLËćţň­ó<ę}×(Ü`Ë̇&oŽ<đ±Aţ]6î:˘a‡E†ní|Eş`°Ó™LÜ•,‡ÇŞřďd%î¸'',pÇ:ń

View file

@ -10,13 +10,15 @@ const gpa = util.gpa;
const data = @embedFile("data/day$.txt"); const data = @embedFile("data/day$.txt");
pub fn main() !void { pub fn main() !void {}
}
// Useful stdlib functions // Useful stdlib functions
const tokenize = std.mem.tokenize; const tokenizeAny = std.mem.tokenizeAny;
const split = std.mem.split; 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 indexOf = std.mem.indexOfScalar; const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny; const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear; const indexOfStr = std.mem.indexOfPosLinear;
@ -30,15 +32,10 @@ const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt; const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat; 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 print = std.debug.print;
const assert = std.debug.assert; const assert = std.debug.assert;
const sort = std.sort.sort; const sort = std.sort.block;
const asc = std.sort.asc; const asc = std.sort.asc;
const desc = std.sort.desc; const desc = std.sort.desc;