advent-of-code

Solutions for Advent of Code.
git clone git://git.amin.space/advent-of-code.git
Log | Files | Refs | LICENSE

commit 14b510aae661fffefe21ef3458efa45f78380a16
parent 212f42d954046003d949165b3b05f18870b89c6b
Author: amin <dev@aminmesbah.com>
Date:   Thu,  6 Dec 2018 06:57:36 +0000

Add asserts for great justice

FossilOrigin-Name: de689db3546da67a9eb7ca124660faa0909cce3496e68e8fb5ab8327a0965538
Diffstat:
Mday_06.zig | 31+++++++++++++------------------
1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/day_06.zig b/day_06.zig @@ -6,9 +6,13 @@ const math = std.math; pub fn main() !void { var allocator = &std.heap.DirectAllocator.init().allocator; + var result1 = try biggest_finite_area(allocator, coordinates); + debug.assert(result1 == 2342); debug.warn("06-1: {}\n", result1); + var result2 = try safe_area(coordinates, 10000); + debug.assert(result2 == 43302); debug.warn("06-2: {}\n", result2); } @@ -48,15 +52,6 @@ fn safe_area(coords: []const V2, distance_threshold: usize) !u32 { test "safe area" { const test_threshold: usize = 32; - const test_coords = []const V2 { - point(1, 1), - point(1, 6), - point(8, 3), - point(3, 4), - point(5, 5), - point(8, 9), - }; - debug.assert(16 == try safe_area(test_coords, test_threshold)); } @@ -134,15 +129,6 @@ fn biggest_finite_area(allocator: *mem.Allocator, coords: []const V2) !u32 { } test "biggest finite area" { - const test_coords = []const V2 { - point(1, 1), - point(1, 6), - point(8, 3), - point(3, 4), - point(5, 5), - point(8, 9), - }; - var allocator = &std.heap.DirectAllocator.init().allocator; debug.assert(17 == try biggest_finite_area(allocator, test_coords)); } @@ -201,6 +187,15 @@ inline fn point(x: u32, y: u32) V2 { }; } +const test_coords = []const V2 { + point(1, 1), + point(1, 6), + point(8, 3), + point(3, 4), + point(5, 5), + point(8, 9), +}; + const coordinates = comptime block: { break :block []V2{ point(67, 191),