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/1/1.zig

21 lines
493 B
Zig

const std = @import("std");
pub fn main() void {
const input = @embedFile("input.asc");
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});
}