diff --git a/.vscode/extensions.json b/.vscode/extensions.json index ffda050..dc730f3 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,6 @@ { "recommendations": [ - "augusterame.zls-vscode", + "ziglang.vscode-zig", "ms-vscode.cpptools" ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b02a726..246e765 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,7 +7,7 @@ "label": "build day 01", "type": "shell", "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": [], "group": "build", }, @@ -15,7 +15,7 @@ "label": "build day 02", "type": "shell", "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": [], "group": "build", }, @@ -23,7 +23,7 @@ "label": "build day 03", "type": "shell", "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": [], "group": "build", }, @@ -31,7 +31,7 @@ "label": "build day 04", "type": "shell", "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": [], "group": "build", }, @@ -39,7 +39,7 @@ "label": "build day 05", "type": "shell", "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": [], "group": "build", }, @@ -47,7 +47,7 @@ "label": "build day 06", "type": "shell", "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": [], "group": "build", }, @@ -55,7 +55,7 @@ "label": "build day 07", "type": "shell", "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": [], "group": "build", }, @@ -63,7 +63,7 @@ "label": "build day 08", "type": "shell", "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": [], "group": "build", }, @@ -71,7 +71,7 @@ "label": "build day 09", "type": "shell", "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": [], "group": "build", }, @@ -79,7 +79,7 @@ "label": "build day 10", "type": "shell", "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": [], "group": "build", }, @@ -87,7 +87,7 @@ "label": "build day 11", "type": "shell", "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": [], "group": "build", }, @@ -95,7 +95,7 @@ "label": "build day 12", "type": "shell", "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": [], "group": "build", }, @@ -103,7 +103,7 @@ "label": "build day 13", "type": "shell", "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": [], "group": "build", }, @@ -111,7 +111,7 @@ "label": "build day 14", "type": "shell", "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": [], "group": "build", }, @@ -119,7 +119,7 @@ "label": "build day 15", "type": "shell", "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": [], "group": "build", }, @@ -127,7 +127,7 @@ "label": "build day 16", "type": "shell", "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": [], "group": "build", }, @@ -135,7 +135,7 @@ "label": "build day 17", "type": "shell", "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": [], "group": "build", }, @@ -143,7 +143,7 @@ "label": "build day 18", "type": "shell", "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": [], "group": "build", }, @@ -151,7 +151,7 @@ "label": "build day 19", "type": "shell", "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": [], "group": "build", }, @@ -159,7 +159,7 @@ "label": "build day 20", "type": "shell", "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": [], "group": "build", }, @@ -167,7 +167,7 @@ "label": "build day 21", "type": "shell", "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": [], "group": "build", }, @@ -175,7 +175,7 @@ "label": "build day 22", "type": "shell", "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": [], "group": "build", }, @@ -183,7 +183,7 @@ "label": "build day 23", "type": "shell", "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": [], "group": "build", }, @@ -191,7 +191,7 @@ "label": "build day 24", "type": "shell", "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": [], "group": "build", }, @@ -199,7 +199,7 @@ "label": "build day 25", "type": "shell", "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": [], "group": "build", }, diff --git a/build.zig b/build.zig index 7d3aff1..58067fc 100644 --- a/build.zig +++ b/build.zig @@ -1,61 +1,35 @@ const std = @import("std"); -const Builder = std.build.Builder; -const LibExeObjStep = std.build.LibExeObjStep; - -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; +const Build = std.Build; +const CompileStep = std.Build.Step.Compile; /// set this to true to link libc const should_link_libc = false; -fn linkObject(b: *Builder, obj: *LibExeObjStep) void { +fn linkObject(b: *Build, obj: *CompileStep) void { if (should_link_libc) obj.linkLibC(); _ = b; - // 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) { - obj.use_stage1 = true; - } - // Add linking for packages or third party libraries here } -pub fn build(b: *Builder) void { - if (comptime @import("builtin").zig_version.order(required_zig_version) == .lt) { - 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. +pub fn build(b: *Build) void { const target = b.standardTargetOptions(.{}); - - // Standard release options allow the person running `zig build` to select - // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. - const mode = b.standardReleaseOptions(); + const mode = b.standardOptimizeOption(.{}); const install_all = b.step("install_all", "Install all days"); const install_all_tests = b.step("install_tests_all", "Install tests for all days"); + _ = install_all_tests; 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("generate", "template/generate.zig"); - build_generate.setBuildMode(.ReleaseSafe); - const run_generate = build_generate.run(); - run_generate.cwd = std.fs.path.dirname(@src().file).?; + 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).? }); generate.dependOn(&run_generate.step); // Set up an exe for each day @@ -64,24 +38,24 @@ pub fn build(b: *Builder) void { const dayString = b.fmt("day{:0>2}", .{day}); const zigFile = b.fmt("src/{s}.zig", .{dayString}); - const exe = b.addExecutable(dayString, zigFile); - exe.setTarget(target); - exe.setBuildMode(mode); - linkObject(b, exe); - exe.install(); - - const install_cmd = b.addInstallArtifact(exe); - - const run_test = b.addTest(zigFile); - run_test.setTarget(target); - run_test.setBuildMode(mode); + const exe = b.addExecutable(.{ + .name = dayString, + .root_source_file = .{ .path = zigFile }, + .target = target, + .optimize = 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 install_cmd = b.addInstallArtifact(exe, .{}); + + const build_test = b.addTest(.{ + .root_source_file = .{ .path = zigFile }, + .target = target, + .optimize = mode, + }); + linkObject(b, build_test); + + const run_test = b.addRunArtifact(build_test); { const step_key = b.fmt("install_{s}", .{dayString}); @@ -98,16 +72,7 @@ pub fn build(b: *Builder) void { step.dependOn(&run_test.step); } - { - 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); + const run_cmd = b.addRunArtifact(exe); if (b.args) |args| { run_cmd.addArgs(args); } @@ -121,42 +86,12 @@ pub fn build(b: *Builder) void { // Set up tests for util.zig { const test_util = b.step("test_util", "Run tests in util.zig"); - const test_cmd = b.addTest("src/util.zig"); - test_cmd.setTarget(target); - test_cmd.setBuildMode(mode); + const test_cmd = b.addTest(.{ + .root_source_file = .{ .path = "src/util.zig" }, + .target = target, + .optimize = 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); - } } diff --git a/src/day01.zig b/src/day01.zig index e701172..3f7627e 100644 --- a/src/day01.zig +++ b/src/day01.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day01.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day02.zig b/src/day02.zig index 5337836..2973141 100644 --- a/src/day02.zig +++ b/src/day02.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day02.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day03.zig b/src/day03.zig index 4f47566..090dcc7 100644 --- a/src/day03.zig +++ b/src/day03.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day03.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day04.zig b/src/day04.zig index 38310c4..9900648 100644 --- a/src/day04.zig +++ b/src/day04.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day04.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day05.zig b/src/day05.zig index 19a1e9f..4cad4eb 100644 --- a/src/day05.zig +++ b/src/day05.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day05.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day06.zig b/src/day06.zig index 1a801ab..ddd37ef 100644 --- a/src/day06.zig +++ b/src/day06.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day06.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day07.zig b/src/day07.zig index c8e53a4..1ccd457 100644 --- a/src/day07.zig +++ b/src/day07.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day07.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day08.zig b/src/day08.zig index 468e0f1..279179a 100644 --- a/src/day08.zig +++ b/src/day08.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day08.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day09.zig b/src/day09.zig index b5bf4ea..2c7ed63 100644 --- a/src/day09.zig +++ b/src/day09.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day09.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day10.zig b/src/day10.zig index dfa1ac5..35fa225 100644 --- a/src/day10.zig +++ b/src/day10.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day10.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day11.zig b/src/day11.zig index a403f6c..2282d62 100644 --- a/src/day11.zig +++ b/src/day11.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day11.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day12.zig b/src/day12.zig index 137a49a..4499d9e 100644 --- a/src/day12.zig +++ b/src/day12.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day12.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day13.zig b/src/day13.zig index cce99a1..672ed52 100644 --- a/src/day13.zig +++ b/src/day13.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day13.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day14.zig b/src/day14.zig index 6d72c95..35e03c1 100644 --- a/src/day14.zig +++ b/src/day14.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day14.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day15.zig b/src/day15.zig index 553095e..a937730 100644 --- a/src/day15.zig +++ b/src/day15.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day15.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day16.zig b/src/day16.zig index 87c7651..ac11d6f 100644 --- a/src/day16.zig +++ b/src/day16.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day16.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day17.zig b/src/day17.zig index 691d886..b5687eb 100644 --- a/src/day17.zig +++ b/src/day17.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day17.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day18.zig b/src/day18.zig index cb3c484..4d431d7 100644 --- a/src/day18.zig +++ b/src/day18.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day18.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day19.zig b/src/day19.zig index e96ddfd..8eb8906 100644 --- a/src/day19.zig +++ b/src/day19.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day19.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day20.zig b/src/day20.zig index 92f0725..19cbe4a 100644 --- a/src/day20.zig +++ b/src/day20.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day20.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day21.zig b/src/day21.zig index 3f3fe4e..6229904 100644 --- a/src/day21.zig +++ b/src/day21.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day21.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day22.zig b/src/day22.zig index b80175e..d3a1036 100644 --- a/src/day22.zig +++ b/src/day22.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day22.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day23.zig b/src/day23.zig index 615687b..fb52558 100644 --- a/src/day23.zig +++ b/src/day23.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day23.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day24.zig b/src/day24.zig index 444daed..274f437 100644 --- a/src/day24.zig +++ b/src/day24.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day24.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/day25.zig b/src/day25.zig index 0969a91..8fcefc8 100644 --- a/src/day25.zig +++ b/src/day25.zig @@ -10,13 +10,15 @@ const gpa = util.gpa; const data = @embedFile("data/day25.txt"); -pub fn main() !void { - -} +pub fn main() !void {} // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -30,15 +32,10 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/src/util.zig b/src/util.zig index 489fe08..0e8cdd0 100644 --- a/src/util.zig +++ b/src/util.zig @@ -11,10 +11,13 @@ pub const gpa = gpa_impl.allocator(); // Add utility functions here - // Useful stdlib functions -const tokenize = std.mem.tokenize; -const split = std.mem.split; +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 indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; @@ -28,14 +31,9 @@ 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.sort; +const sort = std.sort.block; const asc = std.sort.asc; const desc = std.sort.desc; diff --git a/template/generate.zig b/template/generate.zig index c047e77..35e350c 100644 --- a/template/generate.zig +++ b/template/generate.zig @@ -15,7 +15,7 @@ fn instantiateTemplate(template: []const u8, day: u32) ![]const u8 { while (std.mem.indexOfScalar(u8, rest, '$')) |index| { try list.appendSlice(rest[0..index]); try std.fmt.format(list.writer(), "{d:0>2}", .{day}); - rest = rest[index+1..]; + rest = rest[index + 1 ..]; } try list.appendSlice(rest); return list.toOwnedSlice(); @@ -31,7 +31,7 @@ fn readHashes() !*[25][Hash.digest_length]u8 { if (hash_bytes.len != 25 * Hash.digest_length) return error.InvalidFormat; - return @ptrCast(*[25][Hash.digest_length]u8, hash_bytes.ptr); + return @ptrCast(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(@ptrCast([*]u8, mem), 0, @sizeOf(@TypeOf(mem.*))); + @memset(std.mem.sliceAsBytes(mem), 0); break :blk mem; }, error.InvalidFormat => { @@ -49,7 +49,7 @@ pub fn main() !void { std.os.exit(1); }, 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; }, }; @@ -62,7 +62,7 @@ pub fn main() !void { defer gpa.allocator().free(filename); 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: { new_file = true; break :blk try std.fs.cwd().createFile(filename, .{}); @@ -86,7 +86,7 @@ pub fn main() !void { var hash: [Hash.digest_length]u8 = undefined; Hash.hash(contents, &hash, .{}); - regenerate = std.mem.eql(u8, &hash, &hashes[day-1]); + regenerate = std.mem.eql(u8, &hash, &hashes[day - 1]); } else { regenerate = true; } @@ -100,7 +100,7 @@ pub fn main() !void { const text = try instantiateTemplate(template, day); defer gpa.allocator().free(text); - Hash.hash(text, &hashes[day-1], .{}); + Hash.hash(text, &hashes[day - 1], .{}); updated_hashes = true; try file.writeAll(text); @@ -118,9 +118,9 @@ pub fn main() !void { if (updated_hashes) { try std.fs.cwd().writeFile(hashes_file, std.mem.asBytes(hashes)); 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 { std.debug.print("No updates made, all days were modified. Delete src/dayXX.zig to force regeneration.\n", .{}); } -} \ No newline at end of file +} diff --git a/template/hashes.bin b/template/hashes.bin index 6efd6a5..d0b569d 100644 --- a/template/hashes.bin +++ b/template/hashes.bin @@ -1 +1,2 @@ -*3tg iQ[/X1cT7ȣCd`'sR&=R/^ĝ|hJ{-d{|ㆾ4^dzC)ٔ=,IぜO|\Sŧ!V73Z# @GX؍T#hb3Y*a1Ex)Se->;qhvCL;5+XI_f,\L>olvnC7j V|4R7L얝iCq [ &\l=Ǔ>&4RE RhX;"3k}=ӱQOrZF g Vѕy.!>?Ƿh=:: \ No newline at end of file +ػo(aSڪx0QoɉjU!@h@GU/ ,  SsN(a Jq;B}fGQ[&̕ f aMt=2]v|Pՠ>D>=Wq[ϴPZvorrRur[J|W)c^b!Z]sж߾!n'Q {&JqbA `HpIkX`+LuB}7521J +  KߤJ]/%YXatC3AKTzT5GH]L<}(`̇&o