From 0957bf677ef22c6668ccc313506d0535de50b6cd Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sat, 7 Jan 2023 23:07:23 +0100 Subject: [PATCH] Update with use of String. --- day10.c3 | 8 ++++---- day11.c3 | 10 +++++----- day12.c3 | 4 ++-- day13.c3 | 4 ++-- day14.c3 | 6 +++--- day15.c3 | 8 ++++---- day16.c3 | 14 +++++++------- day17.c3 | 10 +++++----- day18.c3 | 2 +- day19.c3 | 6 +++--- day1_1.c3 | 2 +- day1_2.c3 | 2 +- day2.c3 | 8 ++++---- day20.c3 | 2 +- day21.c3 | 12 ++++++------ day22.c3 | 4 ++-- day23.c3 | 20 ++++++++++---------- day24.c3 | 6 +++--- day25.c3 | 8 ++++---- day2_with_more_c3_features.c3 | 4 ++-- day3.c3 | 12 ++++++------ day4.c3 | 12 ++++++------ day5.c3 | 6 +++--- day6.c3 | 2 +- day7.c3 | 10 +++++----- day8.c3 | 10 +++++----- day9.c3 | 2 +- 27 files changed, 97 insertions(+), 97 deletions(-) diff --git a/day10.c3 b/day10.c3 index 4e4fdfc..4468bc0 100644 --- a/day10.c3 +++ b/day10.c3 @@ -44,8 +44,8 @@ fn void part2() { @pool() { - char[] line = f.tgetline(); - char[][] commands = str::tsplit(line, " "); + String line = f.tgetline(); + String[] commands = str::tsplit(line, " "); switch (commands[0]) { case "noop": @@ -76,8 +76,8 @@ fn void part1() { @pool() { - char[] line = f.tgetline(); - char[][] commands = str::tsplit(line, " "); + String line = f.tgetline(); + String[] commands = str::tsplit(line, " "); switch (commands[0]) { case "noop": diff --git a/day11.c3 b/day11.c3 index bc66434..afa4fb7 100644 --- a/day11.c3 +++ b/day11.c3 @@ -34,20 +34,20 @@ fn Monkey[] load_monkeys(Monkey[] monkeys) @pool() { // Very lazy parsing, assuming a lot about the format. - char[] line = f.tgetline(); + String line = f.tgetline(); if (line.len == 0) continue; - char[][] commands = str::tsplit(line, " "); + String[] commands = str::tsplit(line, " "); int monkey_num = str::to_int(commands[1][..^2])!!; if (monkey_num > max_monkey) max_monkey = monkey_num; Monkey* active_monkey = &monkeys[monkey_num]; line = f.tgetline(); - char[][] items = str::tsplit(str::tsplit(line, ": ")[1], ", "); - foreach (char[] item : items) + String[] items = str::tsplit(str::tsplit(line, ": ")[1], ", "); + foreach (String item : items) { active_monkey.items[active_monkey.item_count++] = str::to_int(item)!!; } line = f.tgetline(); - char[][] op = str::tsplit(str::tsplit(line, "= old ")[1], " "); + String[] op = str::tsplit(str::tsplit(line, "= old ")[1], " "); active_monkey.op_is_mult = op[0][0] == '*'; active_monkey.other_op = op[1] == "old" ? -1 : str::to_int(op[1])!!; line = f.tgetline(); diff --git a/day12.c3 b/day12.c3 index 0b6bd3f..a1c862c 100644 --- a/day12.c3 +++ b/day12.c3 @@ -3,7 +3,7 @@ import std::io; import std::math; import std::array::list; -define MapList = List; +define MapList = List; struct Map { @@ -74,7 +74,7 @@ fn Map* load_heightmap() { @pool() { - char[] line = f.getline().str(); + String line = f.getline().str(); foreach (int i, &c : line) { if (*c == 'S') diff --git a/day13.c3 b/day13.c3 index d2bc0f7..29a1f30 100644 --- a/day13.c3 +++ b/day13.c3 @@ -55,7 +55,7 @@ fn void PacketElement.print(PacketElement* element) } } -fn int parse_list(void* list1, char[] list_inner) +fn int parse_list(void* list1, String list_inner) { Packet* packet = list1; int index = 0; @@ -100,7 +100,7 @@ fn int parse_list(void* list1, char[] list_inner) unreachable(); } -fn Packet* packet_from_line(char[] line) +fn Packet* packet_from_line(String line) { assert(line[0] == '[' && line[^1] == ']'); Packet* packet = mem::alloc(Packet); diff --git a/day14.c3 b/day14.c3 index 6bc1e5d..58f072f 100644 --- a/day14.c3 +++ b/day14.c3 @@ -18,9 +18,9 @@ enum EnvType INFINITY_CUTOFF } -fn int[<2>]! str_to_coord(char[] str) +fn int[<2>]! str_to_coord(String str) { - char[][] parts = str::tsplit(str, ","); + String[] parts = str::tsplit(str, ","); return { str::to_int(parts[0]), str::to_int(parts[1]) }; } @@ -35,7 +35,7 @@ fn Environment* load_environment(EnvType type) { @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); int[<2>] last = { 0, 0 }; foreach (part : str::tsplit(line, " -> ")) { diff --git a/day15.c3 b/day15.c3 index 748a225..465f59f 100644 --- a/day15.c3 +++ b/day15.c3 @@ -6,9 +6,9 @@ import std::priorityqueue; define CoordPairList = List][2]>; -fn int[<2>]! parse_coord(char[] s) +fn int[<2>]! parse_coord(String s) { - char[][] parts = str::tsplit(s, ", y="); + String[] parts = str::tsplit(s, ", y="); return { str::to_int(parts[0]), str::to_int(parts[1]) }; } fn CoordPairList load_sensors() @@ -22,9 +22,9 @@ fn CoordPairList load_sensors() { @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); line = line["Sensor at x=".len..]; - char[][] parts = str::tsplit(line, ": closest beacon is at x="); + String[] parts = str::tsplit(line, ": closest beacon is at x="); int[<2>] sensor_at = parse_coord(parts[0])!!; int[<2>] beacon_at = parse_coord(parts[1])!!; list.append( { sensor_at, beacon_at }); diff --git a/day16.c3 b/day16.c3 index 62cd162..1d0b654 100644 --- a/day16.c3 +++ b/day16.c3 @@ -4,14 +4,14 @@ import std::math; import std::map; import std::array::list; -define ValveMap = HashMap; +define ValveMap = HashMap; define IntPairList = List]>; ValveMap v; struct Valve { int id; - char[] name; + String name; int rate; int[10] tunnels; int tunnel_count; @@ -42,10 +42,10 @@ fn Valve[] load_valves(Valve[100]* available_slots) { @pool() { - char[] line = f.tgetline(); - char[][] parts = str::tsplit(line, " "); - char[] name = str::copy(parts[1]); - char[] rate_part = parts[4]; + String line = f.tgetline(); + String[] parts = str::tsplit(line, " "); + String name = str::copy(parts[1]); + String rate_part = parts[4]; int val = v.@get_or_set(name, (int)v.count); Valve *valve_entry = &(*available_slots)[val]; assert(valve_entry.id == 0); @@ -55,7 +55,7 @@ fn Valve[] load_valves(Valve[100]* available_slots) *valve_entry = { .rate = rate, .id = val, .name = name }; for (int i = 9; i < parts.len; i++) { - char[] valve = parts[i]; + String valve = parts[i]; if (i < parts.len - 1) { valve = valve[..^2]; diff --git a/day17.c3 b/day17.c3 index a9360ac..078ec82 100644 --- a/day17.c3 +++ b/day17.c3 @@ -32,7 +32,7 @@ macro bool StateCache.equals(StateCache* cache, StateCache other) return true; } -fn String load_jets() +fn VarString load_jets() { File f; f.open("jets.txt", "rb")!!; @@ -185,7 +185,7 @@ macro long adjust_lowest_bounds() return bound; } -macro @drop_rock(char[] winds, int &shape_index, isz &wind_index) +macro @drop_rock(String winds, int &shape_index, isz &wind_index) { int start = find_height() + 3; Shape* current_shape = &shapes[shape_index]; @@ -195,7 +195,7 @@ macro @drop_rock(char[] winds, int &shape_index, isz &wind_index) { char jet = winds[wind_index]; wind_index = (wind_index + 1) % winds.len; - int[<2>] new_loc = location + int[<2>] { jet == '<' ? -1 : 1, 0 }; + int[<2>] new_loc = location + { jet == '<' ? -1 : 1, 0 }; if (check_collision(current_shape, new_loc)) { new_loc = location; @@ -211,7 +211,7 @@ macro @drop_rock(char[] winds, int &shape_index, isz &wind_index) } } -fn void solve(char[] winds, long rocks) +fn void solve(String winds, long rocks) { game = {}; int shape_index = 0; @@ -272,7 +272,7 @@ fn void solve(char[] winds, long rocks) fn void main() { - String s = load_jets(); + VarString s = load_jets(); defer s.destroy(); solve(s.str(), 2022); solve(s.str(), 1000000000000i64); diff --git a/day18.c3 b/day18.c3 index a7ac449..0d7a51c 100644 --- a/day18.c3 +++ b/day18.c3 @@ -16,7 +16,7 @@ fn void load_lava() { @pool() { - char[][] parts = str::tsplit(f.tgetline(), ","); + String[] parts = str::tsplit(f.tgetline(), ","); locations[str::to_int(parts[0])!!][str::to_int(parts[1])!!][str::to_int(parts[2])!!] = 7; }; } diff --git a/day19.c3 b/day19.c3 index c3744bb..e121155 100644 --- a/day19.c3 +++ b/day19.c3 @@ -40,14 +40,14 @@ fn void load_blueprints() @pool() { Blueprint print; - char[] line = f.tgetline(); - char[][] split = str::tsplit(line, "Each ore robot costs "); + String line = f.tgetline(); + String[] split = str::tsplit(line, "Each ore robot costs "); split = str::tsplit(split[1], " ore. Each clay robot costs "); print.ore_cost = { [ORE] = str::to_int(split[0])!! }; split = str::tsplit(split[1], " ore. Each obsidian robot costs "); print.clay_cost = { [ORE] = str::to_int(split[0])!! }; split = str::tsplit(split[1], " clay. Each geode robot costs "); - char[][] split2 = str::tsplit(split[0], " ore and "); + String[] split2 = str::tsplit(split[0], " ore and "); print.obsidian_cost = { [ORE] = str::to_int(split2[0])!!, [CLAY] = str::to_int(split2[1])!! diff --git a/day1_1.c3 b/day1_1.c3 index 4ad538a..4a388bd 100644 --- a/day1_1.c3 +++ b/day1_1.c3 @@ -14,7 +14,7 @@ fn void main() { @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); if (!line.len) { current_entry = 0; diff --git a/day1_2.c3 b/day1_2.c3 index 6fc3403..e0db585 100644 --- a/day1_2.c3 +++ b/day1_2.c3 @@ -28,7 +28,7 @@ fn void main() { @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); if (!line.len) { update_max(current_entry); diff --git a/day2.c3 b/day2.c3 index 8209ef8..a4a500e 100644 --- a/day2.c3 +++ b/day2.c3 @@ -26,7 +26,7 @@ fault InvalidData FAILED } -fn Choice[2]! choicesFromString(char[] line) +fn Choice[2]! choicesFromString(String line) { if (line.len != 3) return InvalidData.FAILED!; char c1 = line[0]; @@ -36,7 +36,7 @@ fn Choice[2]! choicesFromString(char[] line) return { (Choice)(c1 - 'A'), (Choice)(c2 - 'X') }; } -fn Select! selectFromString(char[] line) +fn Select! selectFromString(String line) { if (line.len != 3) return InvalidData.FAILED!; char c1 = line[0]; @@ -57,7 +57,7 @@ fn void part1() { @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); Choice[2] c = choicesFromString(line)!!; points += c[1].ordinal + 1; // Draw @@ -87,7 +87,7 @@ fn void part2() { @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); Select s = selectFromString(line)!!; switch (s.r) { diff --git a/day20.c3 b/day20.c3 index 9b8b142..232eb9e 100644 --- a/day20.c3 +++ b/day20.c3 @@ -15,7 +15,7 @@ fn void load_crypto(LongList* list, LongList* pos, long key) { @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); list.append(key * str::to_long(line)!!); pos.append((int)pos.len()); }; diff --git a/day21.c3 b/day21.c3 index f82d7e4..dd96d24 100644 --- a/day21.c3 +++ b/day21.c3 @@ -5,7 +5,7 @@ import std::map; import std::array::list; define MonkeyList = List; -define NameMap = HashMap; +define NameMap = HashMap; enum Action { @@ -21,14 +21,14 @@ define MonkeyId = distinct int; struct Monkey { MonkeyId id; - char[] name; + String name; Action action; bool is_human; bool had_human; union { Monkey*[2] other_monkey; - char[][2] other_monkey_unresolved; + String[2] other_monkey_unresolved; long value; } } @@ -45,9 +45,9 @@ fn void load_monkeys(MonkeyList* list, MonkeyId* root_index, MonkeyId *humn_inde { @pool() { - char[] line = f.tgetline(); - char[][] parts = str::tsplit(line, ": "); - char[] name = str::copy(parts[0]); + String line = f.tgetline(); + String[] parts = str::tsplit(line, ": "); + String name = str::copy(parts[0]); if (name == "root") { *root_index = index; diff --git a/day22.c3 b/day22.c3 index 7cff163..2537b02 100644 --- a/day22.c3 +++ b/day22.c3 @@ -15,7 +15,7 @@ enum MapType : char } int[200][200] map; -char[] commands; +String commands; int[<2>] start = { -1, -1 }; int side; int width; @@ -33,7 +33,7 @@ fn void load_map() { @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); if (line.len > width) width = line.len; if (!line.len) break; foreach (int x, c : line) diff --git a/day23.c3 b/day23.c3 index d128e89..bf0a38c 100644 --- a/day23.c3 +++ b/day23.c3 @@ -3,7 +3,7 @@ import std::io; import std::math; import std::array::list; -define CharsArray = List; +define CharsArray = List; // Pick a padding that doesn't hit the asserts. const int PADDING = 100; @@ -11,7 +11,7 @@ const int PADDING = 100; fn void print_map(CharsArray* list) { io::println("-----"); - foreach (char[] line : list) + foreach (String line : list) { io::println(line); } @@ -30,13 +30,13 @@ fn void load_map(CharsArray* list) { @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); width = line.len; line = str::tconcat(&spacing, line); list.append(str::copy(str::tconcat(line, &spacing))); }; } - char[] top_line = array::alloc(char, width + PADDING * 2); + String top_line = array::alloc(char, width + PADDING * 2); top_line[..] = '.'; for (int i = 0; i < PADDING; i++) { @@ -57,7 +57,7 @@ fn bool round(CharsArray* list, int round) { isz max_x = list.get(0).len - 1; isz max_y = list.len() - 1; - foreach (i, char[] line : list) + foreach (i, String line : list) { foreach OUTER: (j, &cref : line) { @@ -68,8 +68,8 @@ fn bool round(CharsArray* list, int round) char* s; char* w; char* e; - char[] north = list.get(i - 1); - char[] south = list.get(i + 1); + String north = list.get(i - 1); + String south = list.get(i + 1); bool nw = is_empty(north[j - 1] ); bool ne = is_empty(north[j + 1]); if (ne && nw) n = &list.get(i - 1)[j]; @@ -117,7 +117,7 @@ fn bool round(CharsArray* list, int round) } } bool elves_moved = false; - foreach (i, char[] line : list) + foreach (i, String line : list) { foreach (j, &cref : line) { @@ -143,7 +143,7 @@ fn bool round(CharsArray* list, int round) } } } - foreach (i, char[] line : list) + foreach (i, String line : list) { foreach (j, &cref : line) { @@ -167,7 +167,7 @@ fn void count_empty_tiles(CharsArray list) isz first_y = 1000; isz last_y = 0; isz elves = 0; - foreach (i, char[] line : list) + foreach (i, String line : list) { foreach (j, c : line) { diff --git a/day24.c3 b/day24.c3 index 5d6cecf..50c05ef 100644 --- a/day24.c3 +++ b/day24.c3 @@ -3,7 +3,7 @@ import std::io; import std::math; import std::array::list; -define CharsArray = List; +define CharsArray = List; const int PADDING = 100; @@ -24,7 +24,7 @@ fn void load_map() defer catch(f.close()); @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); width = line.len - 2; }; height = 0; @@ -32,7 +32,7 @@ fn void load_map() { @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); if (line[1] == '#') break; line = line[1..^2]; foreach (int i, c : line) diff --git a/day25.c3 b/day25.c3 index c46d6ea..a12eb76 100644 --- a/day25.c3 +++ b/day25.c3 @@ -3,7 +3,7 @@ import std::io; int[256] values = { ['2'] = 2, ['1'] = 1, ['0'] = 0, ['-'] = -1, ['='] = -2 }; -fn char[] snafu_from_long(char[] buffer, long l) +fn String snafu_from_long(String buffer, long l) { char[100] temp; isz idx = 0; @@ -40,7 +40,7 @@ fn char[] snafu_from_long(char[] buffer, long l) return buffer.ptr[:idx]; } -fn long snafu_to_long(char[] num) +fn long snafu_to_long(String num) { long value = 0; foreach (long i, c : num) @@ -61,12 +61,12 @@ fn void part1() { @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); total += snafu_to_long(line); }; } char[100] buffer; - char[] res = snafu_from_long(&buffer, total); + String res = snafu_from_long(&buffer, total); io::printfln("%s", res); } diff --git a/day2_with_more_c3_features.c3 b/day2_with_more_c3_features.c3 index 6f5f58d..1df08f8 100644 --- a/day2_with_more_c3_features.c3 +++ b/day2_with_more_c3_features.c3 @@ -37,7 +37,7 @@ fault InvalidData FAILED } -fn Choice[2]! choicesFromString(char[] line) +fn Choice[2]! choicesFromString(String line) { if (line.len != 3) return InvalidData.FAILED!; char c1 = line[0]; @@ -47,7 +47,7 @@ fn Choice[2]! choicesFromString(char[] line) return { (Choice)(c1 - 'A'), (Choice)(c2 - 'X') }; } -fn Select! selectFromString(char[] line) +fn Select! selectFromString(String line) { if (line.len != 3) return InvalidData.FAILED!; char c1 = line[0]; diff --git a/day3.c3 b/day3.c3 index bbce1b3..4c0e2db 100644 --- a/day3.c3 +++ b/day3.c3 @@ -24,11 +24,11 @@ fn void part1() CharSet set; set.tinit(); set.clear(); - char[] line = f.tgetline(); + String line = f.tgetline(); assert(line.len % 2 == 0 && line.len > 0); - char[] comp1 = line[:line.len / 2]; - char[] comp2 = line[line.len / 2..]; + String comp1 = line[:line.len / 2]; + String comp2 = line[line.len / 2..]; foreach (c : comp1) set.set(c, c); @@ -60,9 +60,9 @@ fn void part2() CharSet set2; set.tinit(); set2.tinit(); - char[] line1 = f.tgetline(); - char[] line2 = f.tgetline(); - char[] line3 = f.tgetline(); + String line1 = f.tgetline(); + String line2 = f.tgetline(); + String line3 = f.tgetline(); assert(line1.len && line2.len && line3.len); diff --git a/day4.c3 b/day4.c3 index fd975b9..5040bcc 100644 --- a/day4.c3 +++ b/day4.c3 @@ -1,9 +1,9 @@ module day4; import std::io; -fn int[2]! parse_range(char[] range) +fn int[2]! parse_range(String range) { - char[][] ranges = str::tsplit(range, "-"); + String[] ranges = str::tsplit(range, "-"); assert(ranges.len == 2); return { str::to_int(ranges[0]), str::to_int(ranges[1]) }; } @@ -28,8 +28,8 @@ fn void part1() { @pool() { - char[] line = f.tgetline(); - char[][] parts = str::tsplit(line, ","); + String line = f.tgetline(); + String[] parts = str::tsplit(line, ","); assert(parts.len == 2); int[2] range1 = parse_range(parts[0])!!; @@ -51,8 +51,8 @@ fn void part2() { @pool() { - char[] line = f.tgetline(); - char[][] parts = str::tsplit(line, ","); + String line = f.tgetline(); + String[] parts = str::tsplit(line, ","); assert(parts.len == 2); int[2] range1 = parse_range(parts[0])!!; diff --git a/day5.c3 b/day5.c3 index b745e5c..ab513b2 100644 --- a/day5.c3 +++ b/day5.c3 @@ -14,7 +14,7 @@ fn int init_piles(CharList[MAX_PILES]* piles, File* f) { @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); if (!line.len) return piles_used; int piles_found = (line.len + 1) / 4; assert(piles_found < MAX_PILES && piles_found > 0); @@ -44,8 +44,8 @@ macro void @process_moves(; @body(int move_amount, CharList* a, CharList *b)) { @pool() { - char[] line = f.tgetline(); - char[][] command = str::split(line, " "); + String line = f.tgetline(); + String[] command = str::split(line, " "); assert(command.len == 6); int move_amount = str::to_int(command[1])!!; int from = str::to_int(command[3])!!; diff --git a/day6.c3 b/day6.c3 index abfa7a1..8c16ea0 100644 --- a/day6.c3 +++ b/day6.c3 @@ -21,7 +21,7 @@ fn void find_packet_start(int check_len) { @pool() { - char[] line = f.tgetline(); + String line = f.tgetline(); int len = line.len; for OUTER: (int i = 0; i < len - check_len; i++) { diff --git a/day7.c3 b/day7.c3 index 1718b84..f98c6c3 100644 --- a/day7.c3 +++ b/day7.c3 @@ -6,7 +6,7 @@ define DirList = List; struct Directory { - char[] name; + String name; DirList other_dirs; Directory* parent_dir; long own_files_size; @@ -19,11 +19,11 @@ fn long Directory.total_size(Directory* this) return total; } -fn Directory *handle_command(char[] command, Directory* top, Directory* current_dir) +fn Directory *handle_command(String command, Directory* top, Directory* current_dir) { if (command[2..] == "ls") return current_dir; assert(command[2..3] == "cd"); - char[] dir_name = command[5..]; + String dir_name = command[5..]; switch DIR: (dir_name) { case "/": @@ -51,7 +51,7 @@ fn void parse_dir(Directory *top) Directory* current_dir; while TOP: (!f.eof()) { - char[] line = f.tgetline(); + String line = f.tgetline(); if (!line.len) break; if (line[0] == '$') { @@ -65,7 +65,7 @@ fn void parse_dir(Directory *top) current_dir.other_dirs.append(new_dir); continue; } - char[][] split = str::tsplit(line, " "); + String[] split = str::tsplit(line, " "); assert(split.len == 2); current_dir.own_files_size += str::to_long(split[0])!!; } diff --git a/day8.c3 b/day8.c3 index e6c9d96..a61ceee 100644 --- a/day8.c3 +++ b/day8.c3 @@ -2,7 +2,7 @@ module day8; import std::array::list; import std::io; -define Forest = distinct List; +define Forest = distinct List; fn Forest* parse_forest() { File f; @@ -12,7 +12,7 @@ fn Forest* parse_forest() forest.init(512); while (!f.eof()) { - char[] line = f.tgetline(); + String line = f.tgetline(); assert(line.len); forest.append(line); } @@ -26,7 +26,7 @@ fn int Forest.is_visible(Forest* this, int x, int y) if (y == last_y) return 5; isz last_x = this.get(0).len - 1; if (x == last_x) return 5; - char[] row = this.get(y); + String row = this.get(y); char height = row[x]; int directions_seen_from = 0; do FROM_WEST: { @@ -64,7 +64,7 @@ fn int Forest.scenic_score(Forest* this, int x, int y) { isz last_y = this.len() - 1; isz last_x = this.get(0).len - 1; - char[] row = this.get(y); + String row = this.get(y); char height = row[x]; int scenic_score; int score = 0; @@ -104,7 +104,7 @@ fn int Forest.visible_from_outside(Forest* forest) int sum; for (int y = 0; y < height; y++) { - char[] line = forest.get(y); + String line = forest.get(y); assert(line.len == width); for (int x = 0; x < width; x++) { diff --git a/day9.c3 b/day9.c3 index 75d40b1..4ee0cd6 100644 --- a/day9.c3 +++ b/day9.c3 @@ -69,7 +69,7 @@ macro void part(int $part) defer catch(f.close()); while (!f.eof()) { - char[] line = f.tgetline(); + String line = f.tgetline(); assert(line.len); process_line(&state, line[0], str::to_int(line[2..])!!); }