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");
|
2022-12-02 06:05:23 +00:00
|
|
|
const day02 = @import("day02.zig");
|
2022-12-01 23:12:39 +00:00
|
|
|
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();
|
2022-12-01 23:12:39 +00:00
|
|
|
var timer = std.time.Timer.start() catch @panic("need timer to benchmark solutions");
|
2022-12-01 17:46:44 +00:00
|
|
|
|
2022-12-01 23:12:39 +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-02 06:05:23 +00:00
|
|
|
{
|
|
|
|
try stdout.print("\nDay 2\n", .{});
|
|
|
|
|
|
|
|
const part1_start = timer.read();
|
|
|
|
var part1 = day02.solve_part1(day02.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 = day02.solve_part2(day02.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 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;
|
2022-12-02 06:05:23 +00:00
|
|
|
_ = day02;
|
2022-12-01 23:12:39 +00:00
|
|
|
_ = utils;
|
2022-12-01 17:46:44 +00:00
|
|
|
}
|