summaryrefslogtreecommitdiff
path: root/day-3/main_1.zig
diff options
context:
space:
mode:
authorChristian Segundo2022-12-03 19:28:32 +0100
committerChristian Segundo2022-12-03 19:28:32 +0100
commitee6c6e975dabc6c14f7e8e62e2de1551a431cc7a (patch)
tree834829061b796f3e6168ec1d6b7e1e8ff4469934 /day-3/main_1.zig
parent78fa87cd43cd18f2f9ec4a04c45bcb8036143fd8 (diff)
downloadadvent-of-zig-2022-ee6c6e975dabc6c14f7e8e62e2de1551a431cc7a.tar.gz
refactor to use a meta test
Diffstat (limited to 'day-3/main_1.zig')
-rw-r--r--day-3/main_1.zig39
1 files changed, 0 insertions, 39 deletions
diff --git a/day-3/main_1.zig b/day-3/main_1.zig
deleted file mode 100644
index d65161b..0000000
--- a/day-3/main_1.zig
+++ /dev/null
@@ -1,39 +0,0 @@
-const std = @import("std");
-const slurp = @import("util/file.zig").slurp;
-const dupl_values = @import("util/mem.zig").dupl_values;
-
-var gpa = std.heap.GeneralPurposeAllocator(.{}){};
-const allocator = gpa.allocator();
-
-pub fn main() !void {
- const file_buffer = try slurp(allocator, "./input");
- defer allocator.free(file_buffer);
-
- var iter = std.mem.split(u8, file_buffer, "\n");
-
- var count: u16 = 0;
- while (iter.next()) |line| {
- const duplicates = try dupl_values(
- u8,
- allocator,
- &[_][]const u8{
- line,
- iter.next().?,
- iter.next().?,
- },
- );
- defer allocator.free(duplicates);
-
- for (duplicates) |char| {
- count += char_to_priority(char);
- }
- }
-
- std.debug.print("{d}\n", .{count});
-}
-
-fn char_to_priority(char: u8) u8 {
- if (char >= 65 and char <= 90)
- return char - 38;
- return char - 96;
-}