From: Brendan Hansen Date: Wed, 23 Dec 2020 19:30:51 +0000 (-0600) Subject: small updates to old days X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=64a9468d7c1deee9cb94c73b9c2e9242432f191d;p=onyx-aoc-2020.git small updates to old days --- diff --git a/day17.onyx b/day17.onyx index 49f9929..33187f1 100644 --- a/day17.onyx +++ b/day17.onyx @@ -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 +} diff --git a/day20.onyx b/day20.onyx index d6c1072..75b81f0 100644 --- a/day20.onyx +++ b/day20.onyx @@ -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; diff --git a/day22.onyx b/day22.onyx index a706afe..7500ff3 100644 --- a/day22.onyx +++ b/day22.onyx @@ -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, ","); diff --git a/input/day19.txt b/input/day19.txt index 4bba7fa..ac5c9b4 100644 --- a/input/day19.txt +++ b/input/day19.txt @@ -582,4 +582,4 @@ aaabbbaabbaabbaabaabbbba abbbbbabbabaabaaaaaabbaa bbbabababbbaaababbbabbbabaabaaabbbbbbabbaabbbbbbaabababaaabbabba abababaaaabbababbabaabbbaabbaaabababaababbbaabaabbbaabaa -abbbaabbababaababbbaaabb \ No newline at end of file +abbbaabbababaababbbaaabb