From 3f78c35f9d59ccc4ebee56f110933a2e770637fe Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Wed, 8 Dec 2021 17:08:12 +0700 Subject: [aoc/2021/08/part-two.zig] Use std lib --- aoc/2021/08/part-two.zig | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'aoc') 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).?; } } } -- cgit 1.4.1