about summary refs log tree commit diff
path: root/aoc
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-12-08 17:08:12 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-12-08 17:08:12 +0700
commit3f78c35f9d59ccc4ebee56f110933a2e770637fe (patch)
treef7299bec40befff649ab6e60473c63f94482ea8a /aoc
parent43b7e42dca9ea770ccb094d799480984f8f4bcae (diff)
downloadcp-3f78c35f9d59ccc4ebee56f110933a2e770637fe.tar.gz
[aoc/2021/08/part-two.zig] Use std lib
Diffstat (limited to 'aoc')
-rw-r--r--aoc/2021/08/part-two.zig7
1 files changed, 2 insertions, 5 deletions
diff --git a/aoc/2021/08/part-two.zig b/aoc/2021/08/part-two.zig
index 74db158..294e769 100644
--- a/aoc/2021/08/part-two.zig
+++ b/aoc/2021/08/part-two.zig
@@ -50,11 +50,8 @@ pub fn main() !void {
         while (output.next()) |s| : (pow /= 10) {
             var digit: u7 = 0;
             for (s) |c|
-                digit |= @as(u7, 1) << display[c - 'a'];
-            sum += pow * for (digits) |d, i| {
-                if (@bitReverse(u7, d) == digit) // edian
-                    break i;
-            } else unreachable;
+                digit |= @as(u7, 0b1000000) >> display[c - 'a'];
+            sum += pow * indexOfScalar(u7, digits[0..], digit).?;
         }
     }
 }