-
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
16 changed files
with
654 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 hoof_it = @import("hoof_it"); | ||
|
||
const puzzle_input = @embedFile("puzzle_input"); | ||
|
||
// Benchmark of part 1 | ||
fn task_1(_: std.mem.Allocator) void { | ||
_ = hoof_it.sum_of_trailhead_scores(puzzle_input) catch {}; | ||
} | ||
|
||
// Benchmark of part 2 | ||
fn task_2(_: std.mem.Allocator) void { | ||
_ = hoof_it.sum_of_trailhead_ratings(puzzle_input) 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 10 - Task 1", task_1, .{}); | ||
try bench.add("Day 10 - 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,78 @@ | ||
const std = @import("std"); | ||
|
||
pub fn build(b: *std.Build) void { | ||
const target = b.standardTargetOptions(.{}); | ||
const optimize = b.standardOptimizeOption(.{}); | ||
|
||
// -------------------------- Solution module --------------------------- \\ | ||
const hoof_it = b.addModule("hoof_it", .{ | ||
.root_source_file = b.path("src/hoof_it.zig"), | ||
}); | ||
|
||
// -------------------------- Main executable --------------------------- \\ | ||
const hoof_it_exe = b.addExecutable(.{ | ||
.name = "hoof_it", | ||
.root_source_file = b.path("src/main.zig"), | ||
.target = target, | ||
.optimize = optimize, | ||
}); | ||
|
||
const yazap = b.dependency("yazap", .{}); | ||
hoof_it_exe.root_module.addImport("yazap", yazap.module("yazap")); | ||
hoof_it_exe.root_module.addImport("hoof_it", hoof_it); | ||
b.installArtifact(hoof_it_exe); | ||
|
||
const run_cmd = b.addRunArtifact(hoof_it_exe); | ||
run_cmd.step.dependOn(b.getInstallStep()); | ||
if (b.args) |args| { | ||
run_cmd.addArgs(args); | ||
} | ||
|
||
const run_step = b.step("run", "Run the hoof_it (day 10) app"); | ||
run_step.dependOn(&run_cmd.step); | ||
|
||
// --------------------------- Example tests ---------------------------- \\ | ||
const hoof_it_tests = b.addTest(.{ | ||
.name = "hoof_it_tests", | ||
.root_source_file = b.path("tests/example_tests.zig"), | ||
.target = target, | ||
.optimize = optimize, | ||
}); | ||
|
||
hoof_it_tests.root_module.addImport("hoof_it", hoof_it); | ||
inline for (1..8) |i| { | ||
const num_str = std.fmt.comptimePrint("{!}", .{i}); | ||
hoof_it_tests.root_module.addAnonymousImport( | ||
"example_input_" ++ num_str, | ||
.{ | ||
.root_source_file = b.path("input/example_input_" ++ num_str ++ ".txt"), | ||
}, | ||
); | ||
} | ||
b.installArtifact(hoof_it_tests); | ||
|
||
const test_step = b.step("test", "Run hoof_it (day 10) tests"); | ||
test_step.dependOn(&b.addRunArtifact(hoof_it_tests).step); | ||
|
||
// ------------------------- Puzzle benchmarks -------------------------- \\ | ||
const hoof_it_benchmarks = b.addExecutable(.{ | ||
.name = "hoof_it_benchmarks", | ||
.root_source_file = b.path("benchmarks/puzzle_benchmarks.zig"), | ||
.target = target, | ||
.optimize = optimize, | ||
}); | ||
|
||
const zbench = b.dependency("zbench", .{ | ||
.target = target, | ||
.optimize = optimize, | ||
}); | ||
hoof_it_benchmarks.root_module.addImport("zbench", zbench.module("zbench")); | ||
hoof_it_benchmarks.root_module.addImport("hoof_it", hoof_it); | ||
hoof_it_benchmarks.root_module.addAnonymousImport("puzzle_input", .{ | ||
.root_source_file = b.path("input/puzzle_input.txt"), | ||
}); | ||
b.installArtifact(hoof_it_benchmarks); | ||
|
||
const benchmark_step = b.step("benchmark", "Run hoof_it (day 10) benchmarks"); | ||
benchmark_step.dependOn(&b.addRunArtifact(hoof_it_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 = "hoof_it", | ||
.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,8 @@ | ||
89010123 | ||
78121874 | ||
87430965 | ||
96549874 | ||
45678903 | ||
32019012 | ||
01329801 | ||
10456732 |
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,7 @@ | ||
...0... | ||
...1... | ||
...2... | ||
6543456 | ||
7.....7 | ||
8.....8 | ||
9.....9 |
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,7 @@ | ||
..90..9 | ||
...1.98 | ||
...2..7 | ||
6543456 | ||
765.987 | ||
876.... | ||
987.... |
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,7 @@ | ||
10..9.. | ||
2...8.. | ||
3...7.. | ||
4567654 | ||
...8..3 | ||
...9..2 | ||
.....01 |
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,7 @@ | ||
.....0. | ||
..4321. | ||
..5..2. | ||
..6543. | ||
..7..4. | ||
..8765. | ||
..9.... |
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,7 @@ | ||
..90..9 | ||
...1.98 | ||
...2..7 | ||
6543456 | ||
765.987 | ||
876.... | ||
987.... |
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,6 @@ | ||
012345 | ||
123456 | ||
234567 | ||
345678 | ||
4.6789 | ||
56789. |
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,60 @@ | ||
432109865210212123765432101234321098543289654320132112121058 | ||
045678774324301012892343023445456787650198763013241001034569 | ||
187678789465692321001056014896234986456787012894653212123678 | ||
296589921056789433217837895687145675323891233765784589238987 | ||
345437835434576544786921278761010014210710321212098676521067 | ||
032126546323465435695430789760121223121653450303145125430678 | ||
123010567810156543212345699859834321056544067654236012321589 | ||
543213498987657665401030787348765430187432198765987622345432 | ||
654100332394348972342321895201256589196343089543212331056741 | ||
789011241003238981089400776100343678015434567630105449879870 | ||
296721256210169895676510385011892349101325678921256756768987 | ||
129830787323456765410321294332761058210012310123890891057610 | ||
056745698234556786329454301245656567341110567894781232346521 | ||
145894510149645699438765892398305678956923498965654343765430 | ||
236586789838732388454326765567214307967845697874505652894321 | ||
105675676545321267565810674354303212875430786543216701678912 | ||
234321501656130054278989983289432120123421803403545810787600 | ||
321030432567032123123678100176563018987578912012932921298541 | ||
892349803498145031034563210327898101879647810123871092567432 | ||
785056712387236567687654389410787632768756303294562783458943 | ||
176120987656547858998545076585894583459843214785103698327874 | ||
015431234543218947657898145894983298708941025672234567016761 | ||
329122345692105438941763236783470165617652912341013053205430 | ||
478031001785676323430154100102565674320543805432332122124321 | ||
567649872434985610121894321211056589211230796901440345034234 | ||
456659763323810765456765894323987401108921687878981236565105 | ||
306778654310329876365498765012342322317834510967892387156076 | ||
219865011078478901278321001231451015436123423456785493087189 | ||
652104102569560110669125198340760896895034587655476334196892 | ||
765233243458721321701034567654878987764105694344301243234561 | ||
894310321029832459852567878723965430653298743213210358765410 | ||
132123478010741069743478989014436321541056543401821569898324 | ||
098034569123658978654321876101521087632347812114981678876543 | ||
107765678034567867569270965437698794545938903003470549987432 | ||
256872345621098654378187602348967003897821094012561232789501 | ||
345901436438767789210094511059854112766123285723034341076521 | ||
217894387589656231234543223456743245675054176894125652112430 | ||
306105498678543140567672100145101230984169065765898763203431 | ||
495218321067012056478981041234230121243078434965235678976521 | ||
584349452652100987329891230765345698732154567874143454989210 | ||
673458763643211011010010049874556781235463456963056763474321 | ||
567647601781012567892102156743765470346322161012369812565232 | ||
498678432692123476543103095652834387457210052623871001450143 | ||
304509543543001989698234589501921098768921106780982341019898 | ||
213219601982132670787825676501432349810123235691987432870767 | ||
894348732676544561236910787432321056769894344302346549961251 | ||
765210145690125650345210097899867892110765654219854678450340 | ||
890100126780034743094303126934786543023234565678765012321231 | ||
765987034621129802185412235025696541032167876789874349876012 | ||
876856541234988012276543384110567832249054965694101256778123 | ||
965987650945876543543215493201378980158345434783450126789894 | ||
457871056876067875456906780110234589267210321692569034670765 | ||
320432347780128965307878767820199674307890160541078765521254 | ||
011876548991234534218349856936788765216543254332112340432345 | ||
432965432781049621029256743245215656325321067210003451201056 | ||
547876501632898756540178652101304567101452198760116764342767 | ||
656983432542765987438769789012453898212968765641985895433898 | ||
898792323101874104329054210589562456703879454332076016924567 | ||
125601017652963265012123323676571329894312303549165327810430 | ||
034340178943012378901012334568980016765601212678234456901321 |
Oops, something went wrong.