commit 1a3b342d54a6883f768a0f93b8c317840136c9cb
parent 8730eecf345be6e9c9b629f48a1c2858f08c6cdc
Author: Louis Burda <quent.burda@gmail.com>
Date: Thu, 24 Dec 2020 09:51:56 +0100
day24
Diffstat:
5 files changed, 627 insertions(+), 0 deletions(-)
diff --git a/src/day24/input b/src/day24/input
@@ -0,0 +1,377 @@
+seswenenenenweweenenewneweeeneee
+eswnweswneseseseneeweeweswneeene
+seseseseseswseseswsesesesenesesesenesenw
+enenenweneneenenwneenewneswswnenese
+eswnwswseseseseneeseswweswswwseseswse
+nesesenwswwnwenenwewwswnwwsweenw
+nwnwwwenwnwwsewwnwnewsenwswwnww
+swweseswswsenwneeseseneneseswwsewsesw
+swseesewnwnwnewnwewnesesenwew
+sweneswnenwneneneeeneenenenwenenee
+neeneeseseenwnwnwwenwswnenenewswsesw
+wnwnenenenwesenwswswnenenenenene
+senwsewnwnwnwnwnwwwwewnwnwwnwsenwnw
+eeswneenewseenwneswnenenenwewsesene
+sweeneseneeeseeneewneenenwnwswww
+senenenewwnenenwsesenwswneneneneenenew
+swseswseswwwswneswnwnewwwswswwwnese
+wswwswwnwneseswsewwewwswweswwnww
+newwneswsesweeswnwwwneeneesesenesw
+swenwwseseswswnwnewsewnewseswwnww
+nweeseeenwwweswenenweeneswwee
+newswnwsenwnwsenwwewwesewsweswsene
+esewswsewseeseswsesese
+wseswswseswswswwswsenwwnewswnwwnwsww
+nwnwwwwwwswwenwnwwsewwnwnewnw
+wwnwwnwwwenwnwwenweswewwwww
+nwsenenenwwneneneswnenenenenenwne
+wswwwnwnesewswswnewesenewenwnenwe
+swseseseseneneseswnwsewesesesesesesee
+eneswnwwnewnwwnwnwwnwswswswnewnwnwww
+newwwwwwswwwswsewswswwwnewe
+nwwenwnwnwswnenenwsewseswnwnenwnwnenw
+wwsenwwwswwwewwnwewnewwe
+swnenwsesesenweeseseeseeseswesesese
+nwwnwswnwnwnwenwnwwwnw
+nwwnenenwnwsewenewnwsewsenwnwwsenw
+nwnwseeeseseesenwsweswseseseenwese
+swswwwwwwwwewwwswwsw
+neeewnenewnenenwnenwnewswnwnwnenesene
+nenwwnwsenwsenesenenenweeswneneewsene
+enwnwsesewsesenwneseseeeweseswwse
+swswnwnwswswswwewwwweswswewswswswsw
+nwsenwwnwenwnwnewnwnwnwnweswnwsew
+nwnwnwnweneswsesenwsenenenwnwwesenwnwne
+neneswseseneswwnwswenenwwnwswnwenese
+nenwenwseneneswneswnwswnwnenw
+eeseeneeneneesweeeeesenewwnwe
+swswswswsweswneswswnwswneswnewswswswe
+swseswswswwswswswswswnwswswsweswneswsw
+swswnwnwswseswswswswswseseswswnwseswswne
+wnwnewwwnewwwswwwwswwnw
+wenwewnwnwwwwswnwwwsewnwwwnww
+swswswsewswswsweswswse
+wswwwswwnwwnwsewwsenewnewnewwnw
+swswswswseswswneseswswswwseneswneseswne
+seeseswneswswseswswnwseswsesweswswsew
+senewnwnwswneswenesesenwswnwnenwnwsenwne
+wnenenwwsesewnewnwswsewwswnwnwww
+nenewnenenenwswnenwseenenenwnenenwseene
+nwseswwwwnewnesewwwneswwsewnewnww
+wwwwwnwnwswwsewnwenwnwnwwnwwnwe
+sesewsesesenwnewsweeeneenwsesweew
+nwnwnweswwnewwwwswesweneewsew
+swseswnewwswnwseswseeswswswneseswseswne
+enenwnenwenewwneneneneswnesenenwenww
+wseenweeeseeseneewswswnwnwswnwee
+neswnenenwswneneneenweseneeneeenwene
+senewwnenenwsenwsewswnewswsewwneew
+wnwnenwneswnwnwenenwnenenenwnw
+seswswswswneswswswswnwweseswseswswswsww
+neneenewseenenweeneswnenenenwnenee
+swnwnwenwewnwwswnwenwnwwnwwnwnwnwnw
+nwswnwnwneseswnwnwnwnwnenenewnwnwnenwnwe
+nesesenwseeswwnwenwseweseswnw
+wnwnwenenewswswwwwswnw
+swnewseseseseswseseswsesenesesenenesese
+neneneneneeweswneeneneneenesenwnene
+enwesenweswneeeeweeseneeseee
+eeeeewwseeeseeeweesenwsenee
+eeseseweswesewsesenwnwneeswnewnee
+wwnwseewnwwwwnewnwwwswwswnwww
+newnwsewsenwenenwsewnwsesewnesenwnwnw
+sesweseseseswwswseseswsesesenesenwnwse
+swswseswneswswswwswnesesesw
+nwnenwnwesenwnwnwesenwwseswnwwnwenwsesw
+nwnwneeweewnenwneneewneswwsenenwsenw
+seenwseeeeeeeneesewewesesenee
+nwnwswneesenenenwnwnenwnwwnenenwnwnwew
+esweeeeeeeeeeeeseewwnwee
+swsesesesesenwnwseswnwnwesewseeeseswe
+wwsewsewwwwsewwwwnwwwnwnw
+swwnwswswsweeswnwswswswswswswswswesw
+wnweswwwseswswswswseswnewwswneswnwenw
+eswseeeneeseeeneneneenenenenwnwnw
+nwswswseseseswswseseswsw
+swwneswswswneswswswneswsw
+swseseesenwseeseenwseseseswwsesesesw
+nwnwswsewnwnwnwnwnwnwewnwe
+neneenenesenwsenenenenwnenewnenenese
+neesweneneeneee
+nesenwnenesenwnwswnwnenenewnenenwnenwne
+swswwwwwseswnwnwnwnwswnwswsewesee
+nwsenwsewesweeeseseeeeewsene
+nweswsewswwneswwsenewswneseswsenwne
+sewswweswwnwseeswswwnwnwwneswnwww
+swsenwswwnwseswsewsenweeneseseswnesesw
+eneneneseeseenenweenesenwenewenw
+swseswnesenwseseseseneseseseseswseseseswne
+nwenenwnwnwswneswnwnwnwswnwnwenenwswnwwsw
+senwseseswwnwseseswswswswseneswseswsesese
+ewswenweeeeeeswseeeeeneee
+swswseseseneweseswsesewneseseseesewnenw
+neneswswewsesweswwswnenwsw
+swswwswswswswswswswneswswswswswneswswsene
+eneeneseenenesewneeneenwseewenew
+enwnenenewnwsesenwneneneswnenesenwnwwww
+seswnwnenwnenwnwsenenwnenewnenwnwneewnese
+nwnwwewnwnwnwnwwwwewswwnwnwnwsw
+swwwnwwnwwewwwwwenwweswesew
+swneswwenwwsenewswswnwwseewnwnew
+nesenenwsenenwnwnwnwnesenwnwnenwnenenenw
+swnewswswswswneswnewsenwswneswswwwswsew
+newewnenwswneseewneseseneneeewnee
+nenenwweenenenwneweeseneseneneese
+eseseeseeseswwneeeneswswnweenwenee
+newneswswnwnwwenwnwnwnwenweeneswnw
+eeeneeswwneseneenwsweenweeeenw
+enewsenwsewesesesesesewseeneseese
+swswswswwnwswswsweseeswnweswswswswswswsw
+wwwswswweweeewnewwswwswwsw
+nwseseseesenweswwwnwsweseswseenenwsw
+nwenenwwwwwwnwwsewnwwew
+sewswswnwswswswswsw
+neeneseeeeeeenweeeesewswewe
+swwneswnwswswswnwswswwesewwweswww
+enesesenweswnwneeswnenenewesenwsww
+nweeeseeeseeseswwseenewseneesesese
+senenwswseswwsweeeweneeneseewsenw
+neseswweenwnweswnwnwnwsenwswnwnwnwwenw
+nwsewswswwwswswswswenwsw
+sesenwseesenwseseseeee
+seseswsesweswenenwswseseswsenwswseswswsw
+nenewnenesweneneneenenwnewneneneesw
+wseneenesenwsewnwseswseseseesewsesee
+ewwwswwwnwewwswenwnewnwenwwe
+esweewsweneeneeneneenenwnewswnee
+seswnwsweseswsewswnwswsweswsesweswsw
+eeeewswewseeseneewnwnesenwsenwswe
+wnwswwseswseswwswswswnwwwswewwnw
+eswnwsenwnwnwwnwwnwnenewesweeswnwsenw
+nwseswwwswsenewnewwwewww
+enwneseneneswwnwnwnenenwwnenene
+swsweneeseewseenenwswsesenw
+nwenwwweswnwsesenwenenwnwnewnwnwnwnwne
+neeseswneseneweneneneneswnwneenenweene
+nwnwnwewnwnwneenwnenwswnesenew
+wwswwswswswseswwswswnesweswneswww
+neswwwwwswswsenwww
+senwnwesewnwnwnwswnwnwnwnwnwnwnwnwenwnw
+seeseneenenweeenewee
+eeeweeeeeeseeseenesee
+eeseeeenenwsweeewsweenwe
+newwswwwwwswneeswswswwwwwwswe
+wnenwnewwwwwweseenenwwwsese
+nwswneneewnwenwnwnwnwsenwnwnwnwnwswnewnw
+eseeewweeswseeeeneeeeeee
+neneneweneneneseenwwnenwnenwneneswnesw
+wnwseswnewneseneseeswseseesenesesew
+senenwsenwwwnwnwnwnwnwnewwnwwwww
+nweeeeneeneeeneswneswseenw
+sewseneeeseswnwse
+ewswnwneneeeneseseewnwse
+wseswswwswswnewwsweseswwswwnwww
+newwswnwwswwswwnenesewsweweenwse
+nwnenwsewnwnenwwwwwswnwwswnwnwsesene
+eeswswswswseswswnwwneswswnwswsw
+eneenweneeeeeswswneeneenenwnwse
+nweeneeeeeeeeeeeeswnweswse
+nenesenwnwnesewnwwnwnwnwnesewnenwnwnw
+swwnwnesesenwswnwswsweseeneenwsenw
+wsewsenewnwnenwwwswnwwsenenesewsw
+nwswnewseeeeeswenwwesweneseseseswe
+nwseseseeseseseseseseesesesese
+nwenwswsweweneeeeewnweseswseese
+eeeeeseseenwseseseeenwswneseese
+nenwsweewsewsewnwswnesewnenwseeew
+nwswswenenenenewnenwneenenwneneswnenene
+seseneneeeeweeeseeeswewseeew
+newseeeseseswsesesesesesesenwee
+nwewnenenenwnenenenenwnwswneenenwne
+eeseeeseswnenwwseeseewseeseesesee
+nesewswswwneewnenwswwwwwwwww
+eweneenweeeeeeeseeseeee
+eeeeeewsweeneeseeneneenee
+swswsesesweseswnwswwwnenwne
+sesweneneswswswswnwseswneswswswseswesenwnw
+seseswsewsesenenwseseswsesesenesesesesene
+seseswneswseseseseesenwsewseseesesenee
+eswwswswseseseswswseswwnewswswe
+weswnwenesweseenenweswenweeneenene
+nweseseesesenwswnwneseseenwseewee
+ewswswwswswwswsweswswswwnwe
+seesewneeseeseseewseseseee
+nwsweswseswewswseneneesenwsesesesesee
+senwneneneeswneneewenenwenwseneene
+sewneeeeeweeeeeweeeeesenene
+wnwwsenwnwwenwnwsw
+nwwnenewwnwwswseseewswswwseswwnwe
+swwswswseswwnewwweewwswwwswww
+sweswswnweswswswswswnwswswswsw
+swwwnewswewsewewswswswwsenwnenwesw
+neseseewnwsenenwnewnwnenwnenewnwneswne
+eswneeeeeeneeweeeneeeenesw
+seseseseseseswwseseweseeeneeeee
+swneenenwswweseseswsesenwseswsesewnw
+eeswnweseesweeeseenesenwesesesee
+nwnwnwsenwneswnwnewnwnwneenesenwsenenwne
+sewnwseewwwnewnwwwnewswseswwwew
+neneeeeswsweeenewenwe
+senwwnwnwnenenwwnwnwnwnwwswsenwnwww
+eeseeneeeeeweeneeenwseeww
+swswnwneneewweseswseswswnenwnwswsewsw
+wwswwewswwwwwwewneseswnewswnww
+wsweswnwswnwenenwnwnwnwwnwwenww
+wnwnwnwnwsweswnwswnenewswneenesw
+eneeneseseswsenwswwesenewenenwnwnee
+wwnwnwnwewwnwenw
+swnenwnwswnwnewnwnwnwseeeenwnwswenwsw
+wwwwnwneswwnwwnenewewwwseswwsw
+eswesenweneenenwnweeseeewseeene
+seswseswnwswwswseseseeneswswseseseswse
+weneeeeeneneneneneeweneewnesenese
+wsewwwsewnwswwwnwnwwwwwewwne
+nenwnenwwnenenwsenwnwnenwenwsenwswnwnw
+sweswnweewswswnwwswwwe
+nwnwnwwnwnewnwnwsenenwnwnwwnwnwesewwnw
+wenewnwnwwwnwwwnwwwseswwwwnwse
+seeswwswnwswwnwswneswwswwswswswswswsw
+wswswwnweseneww
+neeeneenenenweeeneeswneneeewsw
+nwwneewwsewswnwnwwswwnewnw
+swseseseesenewswnenwsw
+wwnwsenenwnwnwenenenwwwnwesenesenwnw
+nenwneseneneneneneeewneenwneswnenene
+neeeswnwnwnwswnwnwnwnwnwnwnwwnwnwnwnw
+swswwwesewnwww
+neswneswwnwswnesewwwwswwswswwswsw
+swneswswswneswswwswswswswwswswsew
+nwsewseseneswseseeesweseseesese
+wwnwnesewwwnwwnwnenwnwnwsewwsenww
+nwewwseweeeese
+seswwnwnenenewnesweeneneswnw
+nwsenenenenwnwwneenwnwneenwwnwnenwne
+nenwnwnwnwnwnwseneneseswnenenwnwswnwnwnw
+neswneswsenenwnenenenenenenenenenenenene
+senwseswnenwnesenwneneeneeswnenwe
+swnewnenenwnenesweenewwneenenenenene
+sesenewnwseswsesesesenesesenesewwswsesenw
+swswseswswseseswswswswwswneswnwswneseeswsw
+eneseswwneseewse
+eswsenwnwneseseswnwneeneeenew
+nweneneneeseswnee
+wsenwsewnenwnwneswsweswswswswwwese
+swswswswwsenwswsweswswseseswsw
+swnwwnwwwwenewwewwnwsewnewsw
+nenwsweeeeseswswnwnweee
+newnwseswsenwnwnenwnwsenwnwnenwnwwenenww
+wnwwwnenwnwnwwwenwsewsenenwnwenw
+neneneneneneneenenenwseesenwwewnenene
+nenenesewneeneneneeeneseneneenewne
+nwnwenwnwesenwnwnwnwnwnwwnwnwnwnwswnwnw
+nwnwnwwnwenwenenwnwnwswnwnwnwne
+nwnesenwwneewnwnwnwnwnwnwnwnwnwnwswnww
+wswswswwnwswnesewswweswsw
+wwnweseseneneeneseneesesesenwnwswwswe
+nwswnewenwnwswnwnwnwnwnenweswswnwnwnenw
+wwewnwwwseswswwwwwswwneww
+seeewswwnwsesesenewnenwesenewsesw
+nwswsesenenesweeseeswwwswwwwnwnww
+wswswwnwwnwneseseewwnwnewwwwne
+eneeeneeeeeeew
+sesweswswneswnewswswwswsesewseswswse
+sesesesesesenwneswse
+nwenenwswenwnwnwswnw
+swswswswswswswswsenwswswsw
+seseseswseneseswsewnwsewseseseseswseswsene
+sewwnwnwnwnwesenwnwwnwwne
+newnwnwnwnwnwneenenenenwnwnwne
+nwnwnweswnwswnwnwnwnwnwnwewnwwwenwnw
+neseseseseseseseesewsesenweeesewse
+seswesweesweneeneneewewneeeenw
+wsenenenenenenenenenenenene
+eswswseneseneswswnwswswswswswswswswswsw
+nweeseesweseneenwnwneeeeeenee
+wswnewwswwswseswneeswwnenwswseswnwsw
+enweeeswnweseeeeeeweeeesw
+nenewnweseeneeneene
+wwsewwwwnewnewwwwwwwseww
+eswnwwnwnwswewnwswwwwwnwwnwnwe
+eeenwnweeenwsesweseseeesesewee
+nwseseseeeseeseeenwenewseseswesesese
+swseneeeneeweneswnweneeesenwenene
+seeswswnwswsenesesenwseeseswsenwseneewsw
+neswneneeseneeneesweneenwnewnenenwsw
+nwswseswnenwnwnwnwnenwnwnenwwnwse
+eweneneneneneseseweswneenwwneee
+wsewwwnwsewwnwnenewwwwwwnww
+seeesweeeweseseneewenwesesesenwe
+seseesenwsesesesesesesesese
+swnwseswnwsesweswnwsesesw
+wewswnwwwwwwswwneswsesenewsesww
+eeeeswenenwee
+senweweeeneswnwse
+sewseswnenewsenweesew
+nwneeneenesweeewnweeeeeneesee
+wseswneswnwseneseswwnenwswnwseeswswswse
+neneeenenewenenee
+swenwswswseseswsewnwseswswse
+swwswswsesenweeseweeswwswwswswese
+swswnwnwenwnwsenwwnesenwsenenwnwwsenesw
+swnesweneenenesenenewneswwwesenenewne
+seseswneeeeseseesee
+nesesenwsenesesewseseeswswseseneseneswse
+nwnenwsenenenwnwsenwwnwnwnwnwnwnwwenw
+wewnwwewwwswwsesewnewwswwnww
+neneneseeenenenweenwneneweswenee
+nweswswnwswsenwseswseeswsenwnwswswesww
+wswwsewwwwnwwesewnwwewwnesw
+swwswwwneswwswswwswswww
+enewnenenesenenewwesenenwneneewnenw
+wswswswswswswwsweswswnwswswnwswswswswene
+wneeseseswseswseswsesenwseswseseswsenw
+wnenwnwwnwwsenwnwnesenwnwnesenwseneenwsw
+swnwnwnwnwnwnwnwnwnenwsenwnenwsenwnenene
+neeneeeneswseneeeeeneeneenewnw
+wnenwnwwsweenwnwnwswwswwsenwnwnwe
+sewswseenewneeswswnwwww
+senenwseswswesesesesesenwseswseseseswswse
+nwnwnwenenwnwsenwsenesenwswnwswswnenwnw
+wswewswswnwneeswswwswneswwswsesew
+nweswsesesenwsenwswneseswseswseswseseswnw
+eeweseneweneneeesenwsew
+swsesenwwneseseseswseseseseseneseseswse
+seeeneeseseswnwswseseeseeesesewnw
+seesewenesesesewsese
+nwenwnewswnwnwnwswnwneenewnwsenwsesee
+nwsenenwwnenenwnwnwnenwnenenwne
+swnwswswswswswswswswsweswneswseswsw
+eswweeeneneneneneneseneneneeneswnene
+enwnwwnwwnwenwnwnwnwnwnwnwwnw
+ewswnewnwwewnenesesesewesewnwswne
+swnweseweeseeeneeeseeeseeee
+eneneswweeeeeeeeeesenweew
+nwwnwnwnwenenwswnenwenenwnenwswnw
+eeneswnwwwseewseenewwewweene
+weneseeewwseneeeneeeeseseeswe
+nenwnenenenwnwnenenwwnwnenenesene
+wwwenesewnwwwwwwsenewwnwwww
+neneneeswnenenenwsenewwnenesenenenenese
+nwsenwwnwnewnwwsw
+sesesweesesesesesenwseseewseeesenwse
+nwnwwswnwwwswsewsenwnwnenwwnwwnenwenw
+enwnwneneeeeneneeesweeeneswee
+ewseeseesenweseneseseswnewwsesesesese
+wwseswwswsewwwswwswwswnweswnwwne
+nenwswneweswseeenenwenweswnewnenesw
+wswnwnenwwnwnwneeeswnwnwwwnwswnwnwnw
+eeseswsesesesesenwswnweseseseseeeewne
+swswseseswswswseseseew
+nwnewnenewseneneneeswneneneneenenene
+eseseseseswseseswseseseswnenewseswsewne
+esesewwsesesenenwswsenenewseseneswse
+nwnwwnwnwswnewnwsenwnenwnweeswswwnw
+swnwswswswswswswswnwswswswneswswwseswswe
+neseenwsweeeeeswseswesesenenwnesee
+eesenweswneseeeswewseeseenwsese
+esweesenwnwsewseeenweeeseeswnwwe
diff --git a/src/day24/input-test b/src/day24/input-test
@@ -0,0 +1,20 @@
+sesenwnenenewseeswwswswwnenewsewsw
+neeenesenwnwwswnenewnwwsewnenwseswesw
+seswneswswsenwwnwse
+nwnwneseeswswnenewneswwnewseswneseene
+swweswneswnenwsewnwneneseenw
+eesenwseswswnenwswnwnwsewwnwsene
+sewnenenenesenwsewnenwwwse
+wenwwweseeeweswwwnwwe
+wsweesenenewnwwnwsenewsenwwsesesenwne
+neeswseenwwswnwswswnw
+nenwswwsewswnenenewsenwsenwnesesenew
+enewnwewneswsewnwswenweswnenwsenwsw
+sweneswneswneneenwnewenewwneswswnese
+swwesenesewenwneswnwwneseswwne
+enesenwswwswneneswsenwnewswseenwsese
+wnwnesenesenenwwnenwsewesewsesesew
+nenewswnwewswnenesenwnesewesw
+eneswnwswnwsenenwnwnwwseeswneewsenese
+neswnwewnwnwseenwseesewsenwsweewe
+wseweeenwnesenwwwswnew
diff --git a/src/day24/main.zig b/src/day24/main.zig
@@ -0,0 +1,121 @@
+const std = @import("std");
+const aoc = @import("aoc");
+
+const Color = enum { BLACK, WHITE };
+const Dir = enum { E, SE, SW, W, NW, NE };
+const dirs = [_]aoc.Pos{
+ aoc.Pos{ .x = 2, .y = 0 },
+ aoc.Pos{ .x = 1, .y = -1 },
+ aoc.Pos{ .x = -1, .y = -1 },
+ aoc.Pos{ .x = -2, .y = 0 },
+ aoc.Pos{ .x = -1, .y = 1 },
+ aoc.Pos{ .x = 1, .y = 1 },
+};
+const tokens = [_][]const u8{
+ "e",
+ "se",
+ "sw",
+ "w",
+ "nw",
+ "ne",
+};
+const Tile = struct {
+ color: Color,
+};
+
+fn parseInput(tiles: *std.AutoHashMap(aoc.Pos, Tile), input: []const u8) !void {
+ var lineit = std.mem.tokenize(input, "\n");
+ while (lineit.next()) |line| {
+ var pos = aoc.Pos{ .x = 0, .y = 0 };
+
+ var i: usize = 0;
+ while (i < line.len) {
+ var dir = for (tokens) |tok, ti| {
+ if (i + tok.len > line.len) continue;
+ if (std.mem.eql(u8, tok, line[i .. i + tok.len])) {
+ i += tok.len;
+ break @intToEnum(Dir, @intCast(u3, ti));
+ }
+ } else return aoc.Error.InvalidInput;
+ if (aoc.debug) std.debug.print("{} ", .{dir});
+ pos = pos.add(dirs[@enumToInt(dir)]);
+ }
+ if (aoc.debug) std.debug.print("=> {} {}\n", .{ pos.x, pos.y });
+
+ var tile = tiles.getEntry(pos);
+ if (tile != null) {
+ tile.?.value.color = if (tile.?.value.color == Color.WHITE) Color.BLACK else Color.WHITE;
+ } else {
+ try tiles.put(pos, Tile{ .color = Color.BLACK });
+ }
+ }
+}
+
+fn applyRule(pos: aoc.Pos, before: *std.AutoHashMap(aoc.Pos, Tile), after: *std.AutoHashMap(aoc.Pos, Tile)) !void {
+ if (after.contains(pos)) return;
+ const old_tile = before.get(pos);
+ const old_color = if (old_tile == null) Color.WHITE else old_tile.?.color;
+
+ var adj: u32 = 0;
+ for (dirs) |d| {
+ const tile = before.get(pos.add(d));
+ if (tile != null and tile.?.color == Color.BLACK) adj += 1;
+ }
+
+ if (adj == 2 and old_color == Color.WHITE) {
+ try after.put(pos, Tile{ .color = Color.BLACK });
+ } else if ((adj == 0 or adj > 2) and old_color == Color.BLACK) {
+ try after.put(pos, Tile{ .color = Color.WHITE });
+ } else {
+ try after.put(pos, Tile{ .color = old_color });
+ }
+}
+
+fn doRound(allocator: *std.mem.Allocator, tiles: *std.AutoHashMap(aoc.Pos, Tile)) !void {
+ var result = std.AutoHashMap(aoc.Pos, Tile).init(allocator);
+ defer result.deinit();
+
+ var mapit = tiles.iterator();
+ while (mapit.next()) |kv| {
+ for (dirs) |d| {
+ try applyRule(kv.key.add(d), tiles, &result);
+ }
+ try applyRule(kv.key, tiles, &result);
+ }
+
+ std.mem.swap(std.AutoHashMap(aoc.Pos, Tile), &result, tiles);
+}
+
+fn countBlack(tiles: *std.AutoHashMap(aoc.Pos, Tile)) u32 {
+ var count: u32 = 0;
+ var mapit = tiles.iterator();
+ while (mapit.next()) |kv| {
+ if (kv.value.color == Color.BLACK) count += 1;
+ }
+ return count;
+}
+
+fn part1(allocator: *std.mem.Allocator, input: []u8, args: [][]u8) !void {
+ var tiles = std.AutoHashMap(aoc.Pos, Tile).init(allocator);
+ defer tiles.deinit();
+
+ try parseInput(&tiles, input);
+
+ std.debug.print("{}\n", .{countBlack(&tiles)});
+}
+
+fn part2(allocator: *std.mem.Allocator, input: []u8, args: [][]u8) !void {
+ var tiles = std.AutoHashMap(aoc.Pos, Tile).init(allocator);
+ defer tiles.deinit();
+
+ try parseInput(&tiles, input);
+
+ var round: usize = 0;
+ while (round < 100) : (round += 1) {
+ try doRound(allocator, &tiles);
+ }
+
+ std.debug.print("{}\n", .{countBlack(&tiles)});
+}
+
+pub const main = aoc.gen_main(part1, part2);
diff --git a/src/day24/part1 b/src/day24/part1
@@ -0,0 +1,61 @@
+--- Day 24: Lobby Layout ---
+
+Your raft makes it to the tropical island; it turns out that the small crab was an excellent
+navigator. You make your way to the resort.
+
+As you enter the lobby, you discover a small problem: the floor is being renovated. You can't even
+reach the check-in desk until they've finished installing the [1m[37mnew tile floor[0m.
+
+The tiles are all [1m[37mhexagonal[0m; they need to be arranged in a hex grid with a very
+specific color pattern. Not in the mood to wait, you offer to help figure out the pattern.
+
+The tiles are all [1m[37mwhite[0m on one side and [1m[37mblack[0m on the other. They start
+with the white side facing up. The lobby is large enough to fit whatever pattern might need to
+appear there.
+
+A member of the renovation crew gives you a [1m[37mlist of the tiles that need to be flipped
+over[0m (your puzzle input). Each line in the list identifies a single tile that needs to be
+flipped by giving a series of steps starting from a [1m[37mreference tile[0m in the very center
+of the room. (Every line starts from the same reference tile.)
+
+Because the tiles are hexagonal, every tile has [1m[37msix neighbors[0m: east, southeast,
+southwest, west, northwest, and northeast. These directions are given in your list, respectively, as
+e, se, sw, w, nw, and ne. A tile is identified by a series of these directions with [1m[37mno
+delimiters[0m; for example, esenee identifies the tile you land on if you start at the reference
+tile and then move one tile east, one tile southeast, one tile northeast, and one tile east.
+
+Each time a tile is identified, it flips from white to black or from black to white. Tiles might be
+flipped more than once. For example, a line like esew flips a tile immediately adjacent to the
+reference tile, and a line like nwwswee flips the reference tile itself.
+
+Here is a larger example:
+
+sesenwnenenewseeswwswswwnenewsewsw
+neeenesenwnwwswnenewnwwsewnenwseswesw
+seswneswswsenwwnwse
+nwnwneseeswswnenewneswwnewseswneseene
+swweswneswnenwsewnwneneseenw
+eesenwseswswnenwswnwnwsewwnwsene
+sewnenenenesenwsewnenwwwse
+wenwwweseeeweswwwnwwe
+wsweesenenewnwwnwsenewsenwwsesesenwne
+neeswseenwwswnwswswnw
+nenwswwsewswnenenewsenwsenwnesesenew
+enewnwewneswsewnwswenweswnenwsenwsw
+sweneswneswneneenwnewenewwneswswnese
+swwesenesewenwneswnwwneseswwne
+enesenwswwswneneswsenwnewswseenwsese
+wnwnesenesenenwwnenwsewesewsesesew
+nenewswnwewswnenesenwnesewesw
+eneswnwswnwsenenwnwnwwseeswneewsenese
+neswnwewnwnwseenwseesewsenwsweewe
+wseweeenwnesenwwwswnew
+
+In the above example, 10 tiles are flipped once (to black), and 5 more are flipped twice (to black,
+then back to white). After all of these instructions have been followed, a total of [1m[37m10[0m
+tiles are [1m[37mblack[0m.
+
+Go through the renovation crew's list and determine which tiles they need to flip. After all of the
+instructions have been followed, [1m[37mhow many tiles are left with the black side up?[0m
+
+
diff --git a/src/day24/part2 b/src/day24/part2
@@ -0,0 +1,48 @@
+--- Part Two ---
+
+The tile floor in the lobby is meant to be a living art exhibit. Every day, the tiles are all
+flipped according to the following rules:
+
+
+ - Any [1m[37mblack[0m tile with [1m[37mzero[0m or [1m[37mmore than 2[0m black tiles
+immediately adjacent to it is flipped to [1m[37mwhite[0m.
+ - Any [1m[37mwhite[0m tile with [1m[37mexactly 2[0m black tiles immediately adjacent to it is
+flipped to [1m[37mblack[0m.
+
+
+Here, [1m[37mtiles immediately adjacent[0m means the six tiles directly touching the tile in
+question.
+
+The rules are applied [1m[37msimultaneously[0m to every tile; put another way, it is first
+determined which tiles need to be flipped, then they are all flipped at the same time.
+
+In the above example, the number of black tiles that are facing up after the given number of days
+has passed is as follows:
+
+Day 1: 15
+Day 2: 12
+Day 3: 25
+Day 4: 14
+Day 5: 23
+Day 6: 28
+Day 7: 41
+Day 8: 37
+Day 9: 49
+Day 10: 37
+
+Day 20: 132
+Day 30: 259
+Day 40: 406
+Day 50: 566
+Day 60: 788
+Day 70: 1106
+Day 80: 1373
+Day 90: 1844
+Day 100: 2208
+
+After executing this process a total of 100 times, there would be [1m[37m2208[0m black tiles
+facing up.
+
+[1m[37mHow many tiles will be black after 100 days?[0m
+
+