summaryrefslogtreecommitdiff
path: root/util/aoc.zig
diff options
context:
space:
mode:
authorChristian Segundo2022-12-05 17:00:08 +0100
committerChristian Segundo2022-12-05 22:16:11 +0100
commit061a5bae272f45db6dcde99746922735f9769d25 (patch)
treee4dd9b6d903930c5c1b76286b4a08beea6f59162 /util/aoc.zig
parent8817203517907ef4248bde7474e6fb566515d6a7 (diff)
downloadadvent-of-zig-2022-061a5bae272f45db6dcde99746922735f9769d25.tar.gz
add day 5
Diffstat (limited to 'util/aoc.zig')
-rw-r--r--util/aoc.zig20
1 files changed, 20 insertions, 0 deletions
diff --git a/util/aoc.zig b/util/aoc.zig
new file mode 100644
index 0000000..0c3e668
--- /dev/null
+++ b/util/aoc.zig
@@ -0,0 +1,20 @@
+const std = @import("std");
+
+pub const Result = union(enum) {
+ int: i32,
+ string: []const u8,
+
+ pub fn cmp(self: Result, result: Result) bool {
+ switch (self) {
+ .int => |i| return i == result.int,
+ .string => |s| return std.mem.eql(u8, s, result.string),
+ }
+ }
+
+ pub fn deinit(self: Result, allocator: std.mem.Allocator) void {
+ switch (self) {
+ .string => |s| return allocator.free(s),
+ else => {},
+ }
+ }
+};