diff --git a/src/day01.zig b/src/day01.zig index 0d5f2b7..083027e 100644 --- a/src/day01.zig +++ b/src/day01.zig @@ -17,46 +17,11 @@ pub fn main() !void { const part01_total = try part01(allocator, data); const part02_total = try part02(allocator, data); + std.debug.print("Part01: {d}\n", .{part01_total}); std.debug.print("Part02: {d}\n", .{part02_total}); } -fn replace_number_with_digit(allocator: std.mem.Allocator, word: []const u8) ![]u8 { - var size = std.mem.replacementSize(u8, word, "one", "1"); - const output = try allocator.alloc(u8, size); - _ = std.mem.replace(u8, word, "one", "1", output); - - size = std.mem.replacementSize(u8, output, "two", "2"); - const output2 = try allocator.alloc(u8, size); - _ = std.mem.replace(u8, output, "two", "2", output2); - - size = std.mem.replacementSize(u8, output2, "three", "3"); - const output3 = try allocator.alloc(u8, size); - _ = std.mem.replace(u8, output2, "three", "3", output3); - - size = std.mem.replacementSize(u8, output3, "four", "4"); - const output4 = try allocator.alloc(u8, size); - _ = std.mem.replace(u8, output3, "four", "4", output4); - size = std.mem.replacementSize(u8, output4, "five", "5"); - const output5 = try allocator.alloc(u8, size); - _ = std.mem.replace(u8, output4, "five", "5", output5); - size = std.mem.replacementSize(u8, output5, "six", "6"); - const output6 = try allocator.alloc(u8, size); - _ = std.mem.replace(u8, output5, "six", "6", output6); - size = std.mem.replacementSize(u8, output6, "seven", "7"); - const output7 = try allocator.alloc(u8, size); - _ = std.mem.replace(u8, output6, "seven", "7", output7); - size = std.mem.replacementSize(u8, output7, "eight", "8"); - const output8 = try allocator.alloc(u8, size); - _ = std.mem.replace(u8, output7, "eight", "8", output8); - size = std.mem.replacementSize(u8, output8, "nine", "9"); - const output9 = try allocator.alloc(u8, size); - _ = std.mem.replace(u8, output8, "nine", "9", output9); - - // std.debug.print("REPLACED {s}\n", .{output9}); - return try allocator.dupe(u8, output9); -} - fn find_first_digit_number(word: []const u8) !u8 { var i: usize = 0;