mirror of
https://codeberg.org/andyscott/advent-of-code.git
synced 2024-12-22 01:23:11 -05:00
2024: Day 2/3 ensure deferred input deinit
This commit is contained in:
parent
4f7f33cc75
commit
f75fb88668
2 changed files with 13 additions and 0 deletions
|
@ -18,6 +18,7 @@ pub fn main() !void {
|
|||
const allocator = gpa.allocator();
|
||||
|
||||
const input = try util.readAllInput(2, allocator);
|
||||
defer allocator.free(input);
|
||||
|
||||
var safe: u16 = 0;
|
||||
var safe_with_dampener: u16 = 0;
|
||||
|
|
|
@ -96,6 +96,7 @@ pub fn maybeScan(comptime T: type, window: *std.mem.WindowIterator(T)) !u32 {
|
|||
|
||||
pub fn main() !void {
|
||||
const input = try util.readAllInput(3, allocator);
|
||||
defer allocator.free(input);
|
||||
|
||||
var mul = MulOp.init();
|
||||
var window = std.mem.window(u8, input, 12, 1);
|
||||
|
@ -107,3 +108,14 @@ pub fn main() !void {
|
|||
log.info("PART 1: {d}\n", .{p1});
|
||||
log.info("PART 2: {d}\n", .{p2});
|
||||
}
|
||||
|
||||
test "memory" {
|
||||
const input = try util.readAllInput(3, std.testing.allocator);
|
||||
defer std.testing.allocator.free(input);
|
||||
|
||||
var mul = MulOp.init();
|
||||
var window = std.mem.window(u8, input, 12, 1);
|
||||
const res = try scanForUncorrupted(u8, &window, &mul, 1);
|
||||
try std.testing.expect(res > 0);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue