blob: 72bf8778ffbaa156307055dd811c63b25215b147 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
const parseUnsigned = std.fmt.parseUnsigned;
const print = std.debug.print;
const rotate = std.mem.rotate;
const std = @import("std");
const tokenize = std.mem.tokenize;
const input = @embedFile("input");
pub fn main() !void {
var timer = [_]usize{ 0 } ** 9;
defer print("{}\n", .{ @reduce(.Add, @as(@Vector(9, usize), timer)) });
var list = tokenize(input[0..input.len-1], ",");
while (list.next()) |i|
timer[try parseUnsigned(usize, i, 10)] += 1;
var i: usize = 0;
while (i < 256) : (i += 1) {
rotate(usize, timer[0..], 1);
timer[6] += timer[8];
}
}
|