advent-of-code-2022/src/main.zig

37 lines
1.1 KiB
Zig
Raw Normal View History

2022-12-01 17:46:44 +00:00
const std = @import("std");
2022-12-01 18:13:35 +00:00
const day01 = @import("day01.zig");
const utils = @import("utils.zig");
2022-12-01 17:46:44 +00:00
2022-12-01 18:13:35 +00:00
pub fn main() !void {
2022-12-01 17:46:44 +00:00
const stdout_file = std.io.getStdOut().writer();
var bw = std.io.bufferedWriter(stdout_file);
const stdout = bw.writer();
var timer = std.time.Timer.start() catch @panic("need timer to benchmark solutions");
2022-12-01 17:46:44 +00:00
{
try stdout.print("Day 1\n", .{});
const part1_start = timer.read();
var part1 = try day01.solve_part1(day01.input);
const part1_end = timer.read();
const part1_time = utils.HumanTime.new(part1_end - part1_start);
try stdout.print("Part 1: {} ({d:.2} {s})\n", .{ part1, part1_time.value, part1_time.unit.abbr() });
const part2_start = timer.read();
var part2 = try day01.solve_part2(day01.input);
const part2_end = timer.read();
const part2_time = utils.HumanTime.new(part2_end - part2_start);
try stdout.print("Part 2: {} ({d:.2} {s})\n", .{ part2, part2_time.value, part2_time.unit.abbr() });
}
2022-12-01 17:46:44 +00:00
2022-12-01 18:13:35 +00:00
try bw.flush();
2022-12-01 17:46:44 +00:00
}
2022-12-01 18:13:35 +00:00
test {
std.testing.refAllDecls(@This());
_ = day01;
_ = utils;
2022-12-01 17:46:44 +00:00
}