-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
3,812 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const std = @import("std"); | ||
const zbench = @import("zbench"); | ||
const lan_party = @import("lan_party"); | ||
|
||
const puzzle_input = @embedFile("puzzle_input"); | ||
|
||
// Benchmark of part 1 | ||
fn task_1(allocator: std.mem.Allocator) void { | ||
_ = lan_party.number_of_triples(puzzle_input, allocator) catch {}; | ||
} | ||
|
||
// Benchmark of part 2 | ||
fn task_2(allocator: std.mem.Allocator) void { | ||
_ = lan_party.largest_clique_password(puzzle_input, allocator) catch {}; | ||
} | ||
|
||
pub fn main() !void { | ||
const stdout = std.io.getStdOut().writer(); | ||
var bench = zbench.Benchmark.init(std.heap.page_allocator, .{}); | ||
defer bench.deinit(); | ||
|
||
try bench.add("Day 23 - Task 1", task_1, .{}); | ||
try bench.add("Day 23 - Task 2", task_2, .{}); | ||
|
||
try stdout.writeAll("\n"); | ||
try bench.run(stdout); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const std = @import("std"); | ||
|
||
pub fn build(b: *std.Build) void { | ||
const target = b.standardTargetOptions(.{}); | ||
const optimize = b.standardOptimizeOption(.{}); | ||
|
||
// -------------------------- Solution module --------------------------- \\ | ||
const lan_party = b.addModule("lan_party", .{ | ||
.root_source_file = b.path("src/lan_party.zig"), | ||
}); | ||
|
||
// -------------------------- Main executable --------------------------- \\ | ||
const lan_party_exe = b.addExecutable(.{ | ||
.name = "lan_party", | ||
.root_source_file = b.path("src/main.zig"), | ||
.target = target, | ||
.optimize = optimize, | ||
}); | ||
|
||
const yazap = b.dependency("yazap", .{}); | ||
lan_party_exe.root_module.addImport("yazap", yazap.module("yazap")); | ||
lan_party_exe.root_module.addImport("lan_party", lan_party); | ||
b.installArtifact(lan_party_exe); | ||
|
||
const run_cmd = b.addRunArtifact(lan_party_exe); | ||
run_cmd.step.dependOn(b.getInstallStep()); | ||
if (b.args) |args| { | ||
run_cmd.addArgs(args); | ||
} | ||
|
||
const run_step = b.step("run", "Run LAN Party (day 23) app"); | ||
run_step.dependOn(&run_cmd.step); | ||
|
||
// --------------------------- Example tests ---------------------------- \\ | ||
const lan_party_tests = b.addTest(.{ | ||
.name = "lan_party_tests", | ||
.root_source_file = b.path("tests/example_tests.zig"), | ||
.target = target, | ||
.optimize = optimize, | ||
}); | ||
|
||
lan_party_tests.root_module.addImport("lan_party", lan_party); | ||
lan_party_tests.root_module.addAnonymousImport("example_input", .{ | ||
.root_source_file = b.path("input/example_input.txt"), | ||
}); | ||
b.installArtifact(lan_party_tests); | ||
|
||
const test_step = b.step("test", "Run LAN Party (day 23) tests"); | ||
test_step.dependOn(&b.addRunArtifact(lan_party_tests).step); | ||
|
||
// ------------------------- Puzzle benchmarks -------------------------- \\ | ||
const lan_party_benchmarks = b.addExecutable(.{ | ||
.name = "lan_party_benchmarks", | ||
.root_source_file = b.path("benchmarks/puzzle_benchmarks.zig"), | ||
.target = target, | ||
.optimize = optimize, | ||
}); | ||
|
||
const zbench = b.dependency("zbench", .{ | ||
.target = target, | ||
.optimize = optimize, | ||
}); | ||
lan_party_benchmarks.root_module.addImport("zbench", zbench.module("zbench")); | ||
lan_party_benchmarks.root_module.addImport("lan_party", lan_party); | ||
lan_party_benchmarks.root_module.addAnonymousImport("puzzle_input", .{ | ||
.root_source_file = b.path("input/puzzle_input.txt"), | ||
}); | ||
b.installArtifact(lan_party_benchmarks); | ||
|
||
const benchmark_step = b.step("benchmark", "Run LAN Party (day 23) benchmarks"); | ||
benchmark_step.dependOn(&b.addRunArtifact(lan_party_benchmarks).step); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.{ | ||
.name = "lan_party", | ||
.version = "0.1.0", | ||
.minimum_zig_version = "0.13.0", | ||
.dependencies = .{ | ||
.yazap = .{ | ||
.url = "git+https://github.com/prajwalch/yazap#c2e3122d5dd6192513ba590f229dbc535110efb8", | ||
.hash = "122054439ec36ac10987c87ae69f3b041b40b2e451af3fe3ef1fc578b3bad756a800", | ||
}, | ||
.zbench = .{ | ||
.url = "git+https://github.com/hendriknielaender/zBench#fb3ecae5d035091fd2392a2ec21970c06fc375fa", | ||
.hash = "122095b73930ff5d627429295c669905d85bb9b54394ddc185ad2d61295cc65819e5", | ||
}, | ||
}, | ||
.paths = .{ | ||
"build.zig", | ||
"build.zig.zon", | ||
"src", | ||
"input", | ||
"tests", | ||
"benchmarks", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
kh-tc | ||
qp-kh | ||
de-cg | ||
ka-co | ||
yn-aq | ||
qp-ub | ||
cg-tb | ||
vc-aq | ||
tb-ka | ||
wh-tc | ||
yn-cg | ||
kh-ub | ||
ta-co | ||
de-co | ||
tc-td | ||
tb-wq | ||
wh-td | ||
ta-ka | ||
td-qp | ||
aq-cg | ||
wq-ub | ||
ub-vc | ||
de-ta | ||
wq-aq | ||
wq-vc | ||
wh-yn | ||
ka-de | ||
kh-ta | ||
co-tc | ||
wh-qp | ||
tb-vc | ||
td-yn |
Oops, something went wrong.