about summary refs log tree commit diff
path: root/aoc/2021/08/part-one.zig
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-12-08 15:39:14 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-12-08 15:48:33 +0700
commit43b7e42dca9ea770ccb094d799480984f8f4bcae (patch)
treedba16a7d8066da92225c3081488054111d356bb6 /aoc/2021/08/part-one.zig
parent3e6a252f664e43d0a34805d37e072c9be2c7af8e (diff)
downloadcp-43b7e42dca9ea770ccb094d799480984f8f4bcae.tar.gz
[aoc/2021] Add day 8
Part two is the ziggiest Zig I've ever written!
Diffstat (limited to 'aoc/2021/08/part-one.zig')
-rw-r--r--aoc/2021/08/part-one.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/aoc/2021/08/part-one.zig b/aoc/2021/08/part-one.zig
new file mode 100644
index 0000000..0a9ad93
--- /dev/null
+++ b/aoc/2021/08/part-one.zig
@@ -0,0 +1,18 @@
+const print = std.debug.print;
+const std = @import("std");
+const tokenize = std.mem.tokenize;
+
+pub fn main() !void {
+    var count: usize = 0;
+    defer print("{}\n", .{ count });
+
+    var input = tokenize(@embedFile("input"), "\n");
+    while (input.next()) |line| {
+        var output = tokenize(line[61..], " ");
+        while (output.next()) |digit|
+            switch (digit.len) {
+                2, 3, 4, 7 => count += 1,
+                else => {},
+            };
+    }
+}