fn process_line(l : bytes) : int [ var colon := list_search(l, ':'); var result := ston(l[ .. colon]); var numbers := map(list_break_whitespace(l[colon + 2 .. ]), ston); for ops := 0 to 1 shl len(numbers) - 1 do [ var n := numbers[0]; for i := 1 to len(numbers) do [ if ops bt i - 1 then n *= numbers[i]; else n += numbers[i]; ] if n = result then return result; ] return 0; ] fn main [ var lines := list_break_to_lines(read_lazy(h[0])); var sum := 0; for l in lines do sum += process_line(l); write(h[1], ntos(sum) + nl); ]