small updates to old days
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 23 Dec 2020 19:30:51 +0000 (13:30 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 23 Dec 2020 19:30:51 +0000 (13:30 -0600)
day17.onyx
day20.onyx
day22.onyx
input/day19.txt

index 49f99292f3ff1da01052cbeed906b4e8da098da1..33187f10b51b26ab9fb4e6e7a0e8ebf56f1e744f 100644 (file)
@@ -107,4 +107,4 @@ main :: proc (args: [] cstr) {
     for ^cube_entry: cubes.entries do if cube_entry.value.alive do active_count += 1;
 
     printf("Active count: %i\n", active_count);
-}
\ No newline at end of file
+}
index d6c10725c5699bf5f2f5bb3e255fa3f99781ecd2..75b81f0ddbcc2157d3d3a76b660896a95fa8262e 100644 (file)
@@ -35,7 +35,7 @@ SideRelation :: struct {
     ori  : TO  = TO.N;
 }
 
-TO :: enum (u32) {
+TO :: enum (u8) {
        N;  R90;  R180;  R270;
        F; FR90; FR180; FR270;
 }
@@ -338,21 +338,19 @@ main :: proc (args: [] cstr) {
         tid := to_process[0];
         array.delete(^to_process, 0);
 
-        tile_ptr := map.get(^tile_map, tid.match.tile);
-
-        if tid.pos_x < 0 || tid.pos_y < 0 || tid.pos_x >= 12 || tid.pos_y >= 12 do continue;
         if grid[tid.pos_x + 12 * tid.pos_y] != 0 do continue;
         
+        tile_ptr := map.get(^tile_map, tid.match.tile);
         tile_ptr.pos_x = tid.pos_x;
         tile_ptr.pos_y = tid.pos_y;
         grid[tid.pos_x + 12 * tid.pos_y] = tid.match.tile;
 
         apply_orientation(tile_ptr, tid.match.ori);
 
-        if tile_ptr.edges_match.top.tile    != 0 && tid.pos_y >= 1  do array.push(^to_process, tile_pos_state.{ tile_ptr.edges_match.top,    tid.pos_x, tid.pos_y - 1 });
-        if tile_ptr.edges_match.bottom.tile != 0 && tid.pos_y <= 10 do array.push(^to_process, tile_pos_state.{ tile_ptr.edges_match.bottom, tid.pos_x, tid.pos_y + 1 });
-        if tile_ptr.edges_match.left.tile   != 0 && tid.pos_x >= 1  do array.push(^to_process, tile_pos_state.{ tile_ptr.edges_match.left,   tid.pos_x - 1, tid.pos_y });
-        if tile_ptr.edges_match.right.tile  != 0 && tid.pos_x <= 10 do array.push(^to_process, tile_pos_state.{ tile_ptr.edges_match.right,  tid.pos_x + 1, tid.pos_y });
+        if tile_ptr.edges_match.top.tile    != 0 do array.push(^to_process, tile_pos_state.{ tile_ptr.edges_match.top,    tid.pos_x, tid.pos_y - 1 });
+        if tile_ptr.edges_match.bottom.tile != 0 do array.push(^to_process, tile_pos_state.{ tile_ptr.edges_match.bottom, tid.pos_x, tid.pos_y + 1 });
+        if tile_ptr.edges_match.left.tile   != 0 do array.push(^to_process, tile_pos_state.{ tile_ptr.edges_match.left,   tid.pos_x - 1, tid.pos_y });
+        if tile_ptr.edges_match.right.tile  != 0 do array.push(^to_process, tile_pos_state.{ tile_ptr.edges_match.right,  tid.pos_x + 1, tid.pos_y });
     }
 
     forest : [12 * 8 * 12 * 8] u8;
index a706afeb2b8c6d2dcc9621e0d095c38ae5cc758b..7500ff3e32368eb61c344e570666f6f9d2c5a782 100644 (file)
@@ -45,7 +45,7 @@ combat :: proc (player1: ^[..] u32, player2: ^[..] u32) -> u32 {
 encode_hands :: proc (alloc: Allocator, p1: ^[..] u32, p2: ^[..] u32) -> str {
     use package core.string.builder as b
 
-    builder := b.make(200, alloc);
+    builder := b.make(128, alloc);
     for n: *p1 {
         b.add_i64(^builder, ~~n, 64);
         b.add_str(^builder, ",");
index 4bba7fa5f1cb95dc8adc9157b97f478b7c982672..ac5c9b484edee14b2c2315594b99ee017f0dd40e 100644 (file)
@@ -582,4 +582,4 @@ aaabbbaabbaabbaabaabbbba
 abbbbbabbabaabaaaaaabbaa
 bbbabababbbaaababbbabbbabaabaaabbbbbbabbaabbbbbbaabababaaabbabba
 abababaaaabbababbabaabbbaabbaaabababaababbbaabaabbbaabaa
-abbbaabbababaababbbaaabb
\ No newline at end of file
+abbbaabbababaababbbaaabb