From 332eaae6ee55512027c349cfbce87f7028fa9045 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Wed, 4 Dec 2024 00:03:08 -0500 Subject: [PATCH] 2024: Day 1: use new util.zig --- 2024/day1.zig | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/2024/day1.zig b/2024/day1.zig index 8f8fbad..2f6779b 100644 --- a/2024/day1.zig +++ b/2024/day1.zig @@ -1,16 +1,13 @@ const std = @import("std"); const print = std.debug.print; -pub fn main() !void { - const file = try std.fs.cwd().openFile("day1.txt", .{}); - defer file.close(); +const util = @import("util.zig"); +pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; - defer std.debug.assert(gpa.deinit() == .ok); const allocator = gpa.allocator(); - const stat = try file.stat(); - const input = try file.reader().readAllAlloc(allocator, stat.size); + const input = try util.readAllInput(1, allocator); defer allocator.free(input); var l1 = std.ArrayList(i32).init(allocator);