const std = @import("std"); pub fn main() !void { // read the input file const input = try std.fs.cwd().openFile("input", .{}); defer input.close(); var buf_reader = std.io.bufferedReader(input.reader()); var in_stream = buf_reader.reader(); var buf: [1024]u8 = undefined; var cal : i32 = 0; var max_cal : i32 = 0; while (try in_stream.readUntilDelimiterOrEof(&buf, '\n')) |line| { for (line) |char| { if (!std.ascii.isWhitespace(char)) { // Contains a number const curr_cal = try std.fmt.parseInt(i32, line, 10); cal += curr_cal; break; // else branch not evaluated } } else { // All characters are whitelines max_cal = @max(max_cal, cal); cal = 0; } } std.debug.print("Maximum Calories: {}\n", .{max_cal}); }