From 7b47337e40672c4c5f12a2773d3888c17237f36a Mon Sep 17 00:00:00 2001 From: Xander Bil Date: Wed, 4 Dec 2024 23:58:20 +0100 Subject: solutions day3 and 4 --- main.zig | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'main.zig') diff --git a/main.zig b/main.zig index 4facde2..871eec2 100644 --- a/main.zig +++ b/main.zig @@ -3,8 +3,8 @@ const print = std.debug.print; const day01 = @import("src/day01.zig"); const day02 = @import("src/day02.zig"); - -const Day = enum { day01, day02 }; +const day03 = @import("src/day03.zig"); +const day04 = @import("src/day04.zig"); pub fn main() !void { if (std.os.argv.len != 3) { @@ -27,13 +27,16 @@ pub fn main() !void { const args = try std.process.argsAlloc(allocator); defer std.process.argsFree(allocator, args); - const day = std.meta.stringToEnum(Day, args[1]) orelse { - print("Not valid day or day not yet implemented\n: {s}", .{args[1]}); + const day = std.fmt.parseInt(usize, args[1], 10) catch { + print("Not valid day format\n: {s}", .{args[1]}); return; }; try switch (day) { - .day01 => day01.solve(args[2], buffer, allocator), - .day02 => day02.solve(args[2], buffer), + 1 => day01.solve(args[2], buffer, allocator), + 2 => day02.solve(args[2], buffer), + 3 => day03.solve(args[2], buffer, allocator), + 4 => day04.solve(args[2], buffer, allocator), + else => print("Day not yet implemented", .{}), }; } -- cgit v1.2.3