2024: Day 1: use new util.zig

This commit is contained in:
Andrew Scott 2024-12-04 00:03:08 -05:00
parent efc1516acc
commit 332eaae6ee
Signed by: a
GPG key ID: 7CD5A5977E4931C1

View file

@ -1,16 +1,13 @@
const std = @import("std"); const std = @import("std");
const print = std.debug.print; const print = std.debug.print;
pub fn main() !void { const util = @import("util.zig");
const file = try std.fs.cwd().openFile("day1.txt", .{});
defer file.close();
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){}; var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer std.debug.assert(gpa.deinit() == .ok);
const allocator = gpa.allocator(); const allocator = gpa.allocator();
const stat = try file.stat(); const input = try util.readAllInput(1, allocator);
const input = try file.reader().readAllAlloc(allocator, stat.size);
defer allocator.free(input); defer allocator.free(input);
var l1 = std.ArrayList(i32).init(allocator); var l1 = std.ArrayList(i32).init(allocator);