This repository has been archived on 2022-12-11. You can view files and clone it, but cannot push or open issues or pull requests.
aoc2022/01/1.zig

21 lines
489 B
Zig

const std = @import("std");
pub fn main() void {
const input = @embedFile("input");
var iter = std.mem.split(u8, input, "\n");
var max: usize = 0;
var curr: usize = 0;
while (iter.next()) |value| {
// If not a number, we assume EOF was reached (End Of elF)
curr += std.fmt.parseInt(usize, value, 10) catch {
if (curr > max) max = curr;
curr = 0;
continue;
};
}
std.debug.print("{d}\n", .{max});
}