Update for 2021

This commit is contained in:
Martin Wickham 2021-11-23 22:56:51 -06:00
parent 6b9827d26a
commit 510ff33dd7
28 changed files with 293 additions and 60 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
zig-cache/
zig-out/
build_runner.zig

50
.vscode/launch.json vendored
View file

@ -8,7 +8,7 @@
"name": "day 01",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day01.exe",
"program": "${workspaceFolder}/zig-out/bin/day01.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -20,7 +20,7 @@
"name": "day 02",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day02.exe",
"program": "${workspaceFolder}/zig-out/bin/day02.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -32,7 +32,7 @@
"name": "day 03",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day03.exe",
"program": "${workspaceFolder}/zig-out/bin/day03.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -44,7 +44,7 @@
"name": "day 04",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day04.exe",
"program": "${workspaceFolder}/zig-out/bin/day04.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -56,7 +56,7 @@
"name": "day 05",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day05.exe",
"program": "${workspaceFolder}/zig-out/bin/day05.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -68,7 +68,7 @@
"name": "day 06",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day06.exe",
"program": "${workspaceFolder}/zig-out/bin/day06.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -80,7 +80,7 @@
"name": "day 07",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day07.exe",
"program": "${workspaceFolder}/zig-out/bin/day07.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -92,7 +92,7 @@
"name": "day 08",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day08.exe",
"program": "${workspaceFolder}/zig-out/bin/day08.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -104,7 +104,7 @@
"name": "day 09",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day09.exe",
"program": "${workspaceFolder}/zig-out/bin/day09.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -116,7 +116,7 @@
"name": "day 10",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day10.exe",
"program": "${workspaceFolder}/zig-out/bin/day10.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -128,7 +128,7 @@
"name": "day 11",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day11.exe",
"program": "${workspaceFolder}/zig-out/bin/day11.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -140,7 +140,7 @@
"name": "day 12",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day12.exe",
"program": "${workspaceFolder}/zig-out/bin/day12.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -152,7 +152,7 @@
"name": "day 13",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day13.exe",
"program": "${workspaceFolder}/zig-out/bin/day13.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -164,7 +164,7 @@
"name": "day 14",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day14.exe",
"program": "${workspaceFolder}/zig-out/bin/day14.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -176,7 +176,7 @@
"name": "day 15",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day15.exe",
"program": "${workspaceFolder}/zig-out/bin/day15.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -188,7 +188,7 @@
"name": "day 16",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day16.exe",
"program": "${workspaceFolder}/zig-out/bin/day16.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -200,7 +200,7 @@
"name": "day 17",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day17.exe",
"program": "${workspaceFolder}/zig-out/bin/day17.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -212,7 +212,7 @@
"name": "day 18",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day18.exe",
"program": "${workspaceFolder}/zig-out/bin/day18.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -224,7 +224,7 @@
"name": "day 19",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day19.exe",
"program": "${workspaceFolder}/zig-out/bin/day19.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -236,7 +236,7 @@
"name": "day 20",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day20.exe",
"program": "${workspaceFolder}/zig-out/bin/day20.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -248,7 +248,7 @@
"name": "day 21",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day21.exe",
"program": "${workspaceFolder}/zig-out/bin/day21.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -260,7 +260,7 @@
"name": "day 22",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day22.exe",
"program": "${workspaceFolder}/zig-out/bin/day22.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -272,7 +272,7 @@
"name": "day 23",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day23.exe",
"program": "${workspaceFolder}/zig-out/bin/day23.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -284,7 +284,7 @@
"name": "day 24",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day24.exe",
"program": "${workspaceFolder}/zig-out/bin/day24.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
@ -296,7 +296,7 @@
"name": "day 25",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/day25.exe",
"program": "${workspaceFolder}/zig-out/bin/day25.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",

View file

@ -5,12 +5,13 @@ const LibExeObjStep = std.build.LibExeObjStep;
// set this to true to link libc
const should_link_libc = false;
const test_files = [_][]const u8 {
const test_files = [_][]const u8{
// list any zig files with tests here
};
fn linkObject(b: *Builder, obj: *LibExeObjStep) void {
if (should_link_libc) obj.linkLibC();
_ = b;
// Add linking for packages or third party libraries here
}
@ -26,14 +27,15 @@ pub fn build(b: *Builder) void {
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
// Set up an exe for each day
comptime var day = 1;
inline while (day <= 25) : (day += 1) {
@setEvalBranchQuota(100000); // this comptimePrint is pretty expensive
const dayString = comptime std.fmt.comptimePrint("day{:0>2}", .{ day });
const zigFile = "src/" ++ dayString ++ ".zig";
const install_all = b.step("install_all", "Install all days");
const run_all = b.step("run_all", "Run all days");
// Set up an exe for each day
var day: u32 = 1;
while (day <= 25) : (day += 1) {
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);
@ -43,8 +45,11 @@ pub fn build(b: *Builder) void {
const install_cmd = b.addInstallArtifact(exe);
const install_step = b.step("install_" ++ dayString, "Install " ++ dayString ++ ".exe");
const step_key = b.fmt("install_{s}", .{dayString});
const step_desc = b.fmt("Install {s}.exe", .{dayString});
const install_step = b.step(step_key, step_desc);
install_step.dependOn(&install_cmd.step);
install_all.dependOn(&install_cmd.step);
const run_cmd = exe.run();
run_cmd.step.dependOn(&install_cmd.step);
@ -52,8 +57,10 @@ pub fn build(b: *Builder) void {
run_cmd.addArgs(args);
}
const run_step = b.step(dayString, "Run " ++ dayString);
const run_desc = b.fmt("Run {s}", .{dayString});
const run_step = b.step(dayString, run_desc);
run_step.dependOn(&run_cmd.step);
run_all.dependOn(&run_cmd.step);
}
// Set up a step to run all tests

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day01.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day02.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day03.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day04.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day05.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day06.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day07.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day08.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day09.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day10.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day11.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day12.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day13.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day14.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day15.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day16.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day17.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day18.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day19.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day20.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day21.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day22.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day23.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day24.txt");
pub fn main() !void {
}

View file

@ -2,7 +2,16 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const data = @embedFile("../data/day25.txt");
pub fn main() !void {
}