Skip to content

Commit

Permalink
remove debugging counters
Browse files Browse the repository at this point in the history
  • Loading branch information
milanaleksic committed Dec 14, 2023
1 parent 2277466 commit ee83038
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/day12.zig
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,16 @@ fn run(allocator: std.mem.Allocator, cache: *std.AutoHashMap(u64, i64), field: [
groups[i] = groupNumber;
}

// if (countTotal > 0) {
// print("cache hit: {d} (total attempts: {d}) / cache size: {d}\n", .{ 100 * countHit / countTotal, countTotal, cache.count() });
// }

return try recursiveMatching(allocator, cache, newField, groups);
}

var countHit: usize = 0;
var countTotal: usize = 0;

fn recursiveMatching(allocator: std.mem.Allocator, cache: *std.AutoHashMap(u64, i64), field: []u8, groups: []u8) !i64 {
countTotal += 1;

var hasher = std.hash.Wyhash.init(0);
hasher.update(field);
hasher.update(groups);
const key = hasher.final();

if (cache.get(key)) |cached| {
countHit += 1;
// std.debug.print("Returning cached value {d}\n", .{cached});
return cached;
}
if (field.len == 0) {
Expand Down

0 comments on commit ee83038

Please sign in to comment.