Guest User

Untitled

a guest
Dec 21st, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. const std = @import("std");
  2. const mem = std.mem;
  3. const fmt = std.fmt;
  4.  
  5. const input = @embedFile("../input.txt");
  6.  
  7. fn solve(comptime N: type) N {
  8.     var splitter = mem.split(input, "\n");
  9.     var sum = N(0);
  10.  
  11.     while(splitter.next()) |n| {
  12.         var num = fmt.parseInt(N, n, 10) catch unreachable;
  13.         sum += num;
  14.     }
  15.  
  16.     return sum;
  17. }
  18.  
  19. pub fn main() void {
  20.     @setEvalBranchQuota(500000);
  21.     comptime var answer = comptime solve(i32);
  22.  
  23.     std.debug.warn("part 1: {}", answer);    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment