summary refs log tree commit diff
path: root/24
diff options
context:
space:
mode:
Diffstat (limited to '24')
-rw-r--r--24/Cargo.toml11
-rw-r--r--24/hex.txt42
-rw-r--r--24/input302
-rw-r--r--24/input.small20
-rw-r--r--24/src/main.rs214
-rw-r--r--24/tests/main.rs14
6 files changed, 603 insertions, 0 deletions
diff --git a/24/Cargo.toml b/24/Cargo.toml
new file mode 100644
index 0000000..e9e1108
--- /dev/null
+++ b/24/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "advent_24"
+version = "0.1.0"
+authors = ["Irene Knapp <ireneista@gmail.com>"]
+edition = "2018"
+
+[dependencies]
+advent_lib = { path = "../lib" }
+
+[dev-dependencies]
+assert_cmd = "0.10"
diff --git a/24/hex.txt b/24/hex.txt
new file mode 100644
index 0000000..424d099
--- /dev/null
+++ b/24/hex.txt
@@ -0,0 +1,42 @@
+     ___     ___
+    /0,0\___/2,0\___
+    \___/1,0\___/3,0\
+    /0,1\___/2,1\___/
+    \___/1,1\___/3,1\
+    /0,2\___/2,2\___/
+    \___/1,2\___/3,2\
+        \___/   \___/
+
+
+    / \   / \   / \   / \   / \   / \   / \   / \
+   /   \ /   \ /   \ /   \ /   \ /   \ /   \ /   \
+  |     |     |     |     |     |     |     |     |
+  |     |     |     |     |     |     |     |     |
+   \   / \   / \   / \   / \   / \   / \   / \   /
+    \ /   \ /   \ /   \ /   \ /   \ /   \ /   \ /
+     |     |     |     | 1,1 | 3,1 | 5,1 |     |
+     |     |     |     |     |     |     |     |
+    / \   / \   / \   / \   / \   / \   / \   / \
+   /   \ /   \ /   \ /   \ /   \ /   \ /   \ /   \
+  |     |     |     | 0,1 | 2,1 | 4,1 | 6,1 |     |
+  |     |     |     |     |     |     |     |     |
+   \   / \   / \   / \   / \   / \   / \   / \   /
+    \ /   \ /   \ /   \ /   \ /   \ /   \ /   \ /
+     |     |-3,0 |-1,0 | 1,0 | 3,0 | 5,0 |     |
+     |     |     |     |     |     |     |     |
+    / \   / \   / \   / \   / \   / \   / \   / \
+   /   \ /   \ /   \ /   \ /   \ /   \ /   \ /   \
+  |     |-4,0 |-2,0 | 0,0 | 2,0 | 4,0 | 6,0 |     |
+  |     |     |     |     |     |     |     |     |
+   \   / \   / \   / \   / \   / \   / \   / \   /
+    \ /   \ /   \ /   \ /   \ /   \ /   \ /   \ /
+     |     |-3,-1|-1,-1| 1,-1| 3,-1| 5,-1|     |
+     |     |     |     |     |     |     |     |
+    / \   / \   / \   / \   / \   / \   / \   / \
+   /   \ /   \ /   \ /   \ /   \ /   \ /   \ /   \
+  |     |-4,-1|-2,-1| 0,-1| 2,-1| 4,-1| 6,-1|     |
+  |     |     |     |     |     |     |     |     |
+   \   / \   / \   / \   / \   / \   / \   / \   /
+    \ /   \ /   \ /   \ /   \ /   \ /   \ /   \ /
+     |     |     |     |     |     |     |     |
+     |     |     |     |     |     |     |     |
diff --git a/24/input b/24/input
new file mode 100644
index 0000000..3d24ad2
--- /dev/null
+++ b/24/input
@@ -0,0 +1,302 @@
+nenwneswnwnwneswnenwnwsewenwsesw
+swsesenwswswseseswseswneswseswsweswnese
+neeswsesweneseeenwnenwnewneseewee
+wseeeneseneneeeneneenweneewese
+wwwwsewewsewnwwswwenewwwnww
+seseneeseeswsenwswsewsewseseseneee
+enesenesweseeswswswnwwnwne
+swwwsenwwnwnwnwenwnenwnwsewsewwne
+wnewwseeeswneneneneenweeesw
+swwwswnwnwewwseswwesww
+nwneswswswnweswweneeeneewwswswswne
+senwseswsewseseseesesenwesesenweseesw
+senesewneenwnwwesewnwesesesenewne
+swwnwnwwwnwnwwewwnenwnwswsenwwnenw
+swnwneseewnwnwnenwenewnwnw
+swesesweswseswswnwnwsewnwseswseeswsw
+nwnwnwsenwnwnwnwnwsenwwenwnwsewnwwneswnw
+wwwewnwnwswwwneseeeswnwnww
+swswswswseswneswseseneneswneseswswnewsw
+swneseswswseseseswswswseswswse
+wnewwwswnwnwwwwnwwsenww
+senwsenewseneswwnene
+nwseeswsesenesenwseseseseswsesenwseseswsw
+wwswwswsewnewewwwwwwwwwnenesw
+wwnwewenewweswnewswse
+swwsenwwnwwwnwwseenwnwwnwnwnwenww
+wwnenewswwewwswwwwsewwnwww
+swenwnweseeseeeewe
+nwewseeeesesese
+nwsewesweesenwnwswseesewewswswse
+wewsewwswwwnwewwwswnewwww
+swswwneswwswswwwswenesene
+seseseswswseswseswwseswswnesesw
+newnwwwnwwwsewwnw
+eswseenwseeeeeeswsenwneeeeee
+swswsweswneenwneweneneneeeneesesw
+swnwswesweneswswneseswswwswnw
+eeeweeeesweneweneeeeeese
+esesesesewnwswseswnesesesenweseseseew
+nenwsenwnwnwsenenenenenwnewnenwnenesese
+neenwneneneenwneneswnenwewneneeswswnenw
+swseeswswswswenwswswswnwswswswsesw
+nwnwswnwwenwnweneenwswnwsenwswnwsese
+wenwweswseswswswswswwnwswswneenww
+wswesenenwnwwenwwnwswnwnwnwnw
+wnwnwnwsenwnwwnwnwnwwnwnw
+ewesweeeeenenenwneswswseeeweee
+nwenweeeeweeseeenwsweseeesese
+senewneneneneswnenwseenwsenesewnwnenwse
+senwseewewseenwseseseseswese
+eeeeneswsenweeee
+ewnenwnweswnwwswswnwnwnenesesewese
+newnwswwnwenwwnwnwswwswnwwwwenw
+nwseewwnenwnwnwnwnwnwnwsenwnwnwwenwnw
+ewnenenwnenenenenwesewswwnwnenenee
+seseswsesesenesewsesesenwseseewnwsese
+nwswseseseeseneswnwwseeeesenweswwe
+enwnwnesenwnenwnwnenenwwnenwsenwnwsenw
+wewnweseeswneenenwseeeeeseee
+sesesesesewseswseseseesesese
+neeeeeneeswneseenwnenenwneswenwe
+sewswswesweswsewseseswnwneeswnwenw
+wnenenewswseneeenewseeenw
+neswnwnenwwewnwnwnwnwnwseweswnwese
+swnwswsewswswnenwnewsewwwwneseswse
+wwswsweswwswswswswswswsw
+esenewneneseweeenenew
+nwswewnwsenwnwenwnwwsewwnesenwnwse
+wenwweeseseswewenenweeeesew
+sesenwswnwnwnenenwnwnewnesenewnenenenww
+sesenesweswwesenwswnw
+nwsenwswnenwnwnwsenewneswsenwwsenwnwnwne
+nenenwswnwnwnenenwnwnwnwnwsenwneewnesw
+nwneneeseeswsenwesewseswwseswwnesene
+nwnwnwseneenwnwnwnwneswswnwsweenwnwnww
+swnenesewnwseneswnwswseeseswseeenese
+newneneneneneeswne
+nenwnenwnewnenenenenwneswsesenwnenwnene
+swwnwnwewnwnenwnwnwnw
+wseenwswsenenewnwswswnwnenwnwswenwsenw
+enenewnewnwnwneeneneseswswnwseneew
+neneeneeneneswnenewnenwe
+senewnwswsenwnenwsenwsewnwwneenwnwsw
+nenwneeneeeneneeese
+neswswswesewwswwswswsenesewswneswnew
+wwsewwnwwwwwwnwnw
+neneeeeeeeneswnewneneeseneneew
+swswswswwwswswwnesw
+seeneneewweenese
+eswnwsweswswwnwseswswswneswseeswswne
+wwnwswwwnenwnwwnww
+nwseeswnwneeseswseseweseneesweseee
+eseseseseeseeseseseenwsese
+swesenwswseswswsewsesenesese
+enesewnwswswnenenenenwneneneswsenwnenw
+wnwwsesewwnewswwwwnwnwwwenwe
+eswswswseswwnwnwswsweseswenwsw
+enwswseswwwswnwswneswswwwseswswswsw
+wsenwswswswswsweeneswwwwswwsw
+esenwewwwwwwwwwwewwwww
+neneneseenwsenwsenwswwwseenewnenesese
+nwweswwsenwnwesweweswnwwenwenww
+eseswsesesesenesesesesewewsenwnww
+newesenwnenenenenwneneneswnesenenenewne
+ewnwswnenwnwsenwsenwsenenwnesenwneswnwne
+nwwswnwsewnenesesweenwnwnwewnenwnw
+swnweswswwswswswswswnwseswswswsw
+eewwswnewswewenwnwseneseenwsenwe
+nenwswnwenwnenesewnenwseneswseswnwnenene
+neneswnwwnwewsewenwsesw
+senwseseseseseseswsenwsesesesesesesenesenw
+enewsewwnwnwseswnenwswnwwnwwnenwnw
+wswwwwswswnweswswwswwwwwwenwe
+swswneswseseseseswswsw
+wwswsenewwwwwswwswneww
+wseeeewneseese
+nesewwseseseswseseesw
+nwenwnwswnwnwswenwswnwenwnwsenwnenenwnwnw
+seswswswseswseneswseswswswneneseenesenwse
+wswswwswwswswsweswnwswsweswenwewsw
+sewsenwsewseneeswseeswse
+eewweewneeneeeseneweeswnene
+weeeenwesenweeseseewnewsenwse
+nenenewneswneswneneneeneneneeeseneswe
+wnwneneseenwewseswswswswneswwswnene
+nweeswwwseseeseweswswnwsenwswswse
+eneweenenwseweesenww
+swnenewnweneseewnenwnesenenwenwnenwnesw
+seseswseseswesenesesewswsesw
+neeseweneeesewseeeneenwweeseee
+newseneswnenwnwnesenenwnwnwenwwnwnwnw
+enwnwenwnwwnwnwnwnwnenwnenwswswneese
+ewwwwswwwswswwswnewswnew
+sesesesenwseseseseseesese
+nwnwwsewnwnwnenwwenwswseseenwnwswne
+wswneneswswseswseswewwsesesweseneswnwnw
+wnwsewwwwnwswwwwwwwenwew
+nwnwnwnwnwnenwnwnwsww
+wswswswnwswwswnwsenwseneswsweswswseswsw
+nesenwneseswseswwnwneseswsesesenwswesese
+nwnwnenewsenwneseenwnenwnwnwneseneswnwswne
+nenesesenenenwnwswneeewnenenw
+swnwswseswswwnwwwwswswnenewsewswswese
+swenenwnwnwnenenwswnenwnenesweenenwnw
+eeswenewenwneswneneeneenenenee
+swswsweswswneswswswnenwswsweswnwsenwne
+eeeesesewesenwesw
+wwswswseneswsesenwseseneseeswseenwnwsw
+swwwwewswwesw
+wswwswwnewwseswswswswewswnwwnesw
+eswsenwseswneewenweeewwwneene
+wwewweswswwwswwewswwnwwwnw
+swwneeenwnenwnwwswnenwnwnwweenwne
+eneseneneswneneeneseneenweweswwnw
+nwesesesesweeseneseesesesesesenwsenw
+wwwwwwwwneswwseswwnesewwswesw
+wnwesenwnwsenwwwnwwnwnwwwnewswwnw
+eneewneeeneneneneneeenewese
+sesesenesewsesesesesesenwsesesesenw
+seswsenenwwsewseneneseeseswswswsesesese
+swnenwswnwnewnwswswwnweewsesesewwne
+ewneswswneswnwnwwsewneneseswseswsesee
+wswswwswwnewwswwswswwewswsewe
+swwnwnenenesewnenwwnwneneeweeswsene
+eseswseseeseeeeneeswneneneweswee
+eseseseenenesesesesewneseseseseseww
+enesenenenwneneneneenenene
+wswwswwwnewnwwsenewnwwnewseew
+nenenenwneneeenwnwwswswnenenwenwnesw
+nenenwnewswneneneneseneenenenenenesene
+nenenwnwnwnwsenwnwnwnw
+swwnweenwneneneeswnenenenenewswsenenenw
+eswnenwswswnwwewneseesweseneenww
+nenenenenwwnenwneneenenenw
+sesewswneswswswseswneswswsenwswseswswse
+esesweeeeneneesweeeenwwnwneee
+wwwwnwwnwwsenenwwwwwnwwswseew
+nweseneswnenenenenenenwnenwnenwne
+wnwnwsenenewnwsewsenenenwewsenwwee
+wnwseswsesesweesesenwseswswse
+nwnenwwnwwneneneeswseneneeswnwnesene
+neswsesesesewsesesenwswseesesesesewnesese
+nwwwswwwewwww
+swsweseseseseneswnwnesewseseswseseswsw
+esesenwseseswwseseesenwnenesesesewsew
+eseswswnwswnwsesewesesweswsw
+wwwnwwwenwsenwnwnwwnw
+wnwnwnwnwnwnwwnwnwnwnwnenweesenwwswnwsw
+swswsesweenwnwwnene
+swswswwneneneswwsesenwwswnwnwwwsee
+nenwsenwenwenwsenenwnwnwnwneswnenwnww
+swewwnenweswnwswwnwnwwwnwnwwwww
+newneneenenenenenenenenee
+swewnwswswneeswseseswnesenwenwwswsesw
+wnewwswenwwwwswnwwwnewnwnwsww
+nesenwswsweneseswneesesewswnenwsesesese
+sewswswswwwnewswswwnwwnewwwswwsee
+seeeewswneseewsesenenweseesesese
+nenwneswnenenwnwnwwnwenwenenenwnwnwsw
+enenwsenwwnwneswseseseenewseswsenww
+newswswwswwswswwswnwwwswswneesesw
+nwswswnwnwswseswswwneseenwwswe
+nwwwswseneneneneneenwneneneneneenenene
+senwsenwwwwwsewwwwneswnenwwww
+swswwswsenwswseesesewnenenenewswsweswnw
+swweneenwwsenwneneeneseneeene
+nwnwnenwswenwnwwnwewnwnwsenwnenwnewnwe
+eenenwneswnenenese
+senwnwneseseeewswsesewsewenesesese
+neswwwewwnenwwswwseswnw
+wseeeneswseseeseseseseneneseseswsese
+senenewesenwesenwswwwswnwsesenwenw
+nweneneeeseeeeeseenwweeeswne
+wswswseseswswswwnwnenwsweswswswswwsw
+nenwswnwenwneswseesenenenewneee
+nwnwnwnwnwnwenwswnwnwnwwnw
+seseseseseneswseseseswswsw
+eswswnewwswsenweswwwnwswswesenww
+nenenenwwnwneenenesesenenewne
+neeeswneswnweeeeeneneeswneenenew
+weswswenwseswswswswsenwswsw
+nwnwnwnwnwwenewwneewseseswnww
+nwwsenwwswswneeneswswswsesweswswnesenee
+wswwneswswswweseswnewnewnenesesesenenw
+sweseseswswswsewsw
+eeenewseneeweseenenewneseeneenee
+seseenwnwseseseeseseeeneweseseseew
+wwewnwnwwwsweew
+sewnwnenwnwesenwwnenwnwwnwneswwwsew
+wswwwswwsenwnwwwneswewswenwswswwsw
+nwnenenenenewenenenenenwnene
+sewnesewsewsewnenwwwwnewnwnwww
+nwsewneeswwsewneswnwweenwnenw
+eseeseseneseseweesesenwsesese
+eneenenewenwswnwseswsenweeeeee
+sesenwweesesesesesesenesewsesesesese
+eneenwneeeewseenewewnweswseswe
+swwswswswswswweswnweswswswswsesweswswnw
+eewseeeenweeeenweswseseesee
+nwnwneeswnwnwwnwwswswneswswnwnwenwswene
+eenwnwswesenwsweswsesenweseenwee
+wwnwwwewwnwwnenwwwsw
+swnwnwneswenwenenenewenwswseswewse
+nenwnwnenwnwnwnwnwswnwnwnwnw
+nweswneeeswnweswswenwsweswneeenenwne
+nwnenwneesewnewnwesenwnwnenwnewnwnwnww
+ewwwwswswwenwwswswswwsesw
+nwesewnenwesewseswnenweswseewseseee
+nwswwsweswswseswwswswswnwswnwswswwe
+wenwseewseeseneeseswswseseenwsene
+seswswsesesesesesesenw
+enenewenenenwnenwnenenwnenwswseswne
+swwwsesewwwnwsewwsewnenwnwwwwww
+wsenwwnenwnwsenwseseseseswseswneenesese
+sweeeenwsenwnesenenwswswewwnwesww
+swseswswswswsenwswswsw
+nwswnwswnwnenwnwnwenwnwnwnenwnewnwnwnwsew
+weeeeseweseweneenwsweeseenew
+nwswswseswswswseswswswsw
+eswsenwswsesenwswneneeenwneseswwswse
+seseseseeseseseeenewsesese
+swnenesweweenwneeeneneseeeeee
+wwwwnwwwsewwnesewwnewse
+neeenenwnenwswswnwseneeeeesweee
+neenenenenenenwenewnenwswneswenwnene
+wseeenesesenwneesenweeseswswswswse
+esenwweswwewnenwewseenwsenwsee
+newneeseeseeswewseeesesenweeesee
+esewnwsenenewswnwwwsenwseswnwewnww
+neneneeneenwewweneswseneneneneese
+neewswnwweseswneesweswnwenwenenw
+wwnwwnwwwwwwwsewewww
+seseseneseswsesewseswseseswnwsee
+esweeswseweseseeeenwswenwneene
+sesenwwseseneseswswnwswsewseseseseseene
+eeesenwsweeenwneeswswneesenewne
+nenwnwnenenwnenenwwewewnwesenwswnw
+nwnwnwwnwseenwenwnwnenwnwnwwnwnwwne
+wneseeeenenewnwnwwneneesweswnene
+wwnwwwnwsenwwewwnwsenwnwwwnew
+nwnwnwnwnwwnwnwwswsesenewenwnwnwnwww
+eswwsewnwwsewwnwwwwewwwenwsw
+nesweswnewswnwswswewwnwsenwsenwwnwse
+nwnwwwnwwweweswsenwwsewwneeww
+neeenwswswnwswsweneneenwneeeneeneee
+nwnwnesenwsewnwnenenwsewnwnee
+eeenwesenwsesenweesweseseeswesee
+eewwwwswwswswwswnewwnwnwesww
+sewnenesenwnwswswnenwseneswwnenwnenwesw
+ewswnwnwnwenwnwnwnwnwwswnwwenwenw
+nwnwnwnwsenwnwnwnwnwnwnwnwwnw
+newwwswswswswseswswswswswesw
+swswswwwswwesenwswwneswswswwswsw
+neeeenenweeeneneesw
+seesesenwenwsewseenwsewswnweneew
+swnesenesenesewsweneeswnwsesenwwese
+eswnwswwswsenesenew
+swneswwenwnenwsenenewwswesenenenenw
+wwwwwwwwnwswneeseswneesesw
+sesenwnwwnwwnesenwnwnwwnwswenwnwwene
+swswswwsesweseswswwswnwswswsesesenee
+nwnwswwnenenwnwwnwwnweswnwsenwnwnwnwnw
diff --git a/24/input.small b/24/input.small
new file mode 100644
index 0000000..3dc2f67
--- /dev/null
+++ b/24/input.small
@@ -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/24/src/main.rs b/24/src/main.rs
new file mode 100644
index 0000000..21b3568
--- /dev/null
+++ b/24/src/main.rs
@@ -0,0 +1,214 @@
+use advent_lib::prelude::*;
+
+use std::collections::BTreeSet;
+//use std::convert::TryFrom;
+
+#[derive(Clone,Copy)]
+enum Dir {
+  East,
+  West,
+  Northeast,
+  Northwest,
+  Southeast,
+  Southwest,
+}
+
+
+fn main() -> Result<()> {
+  let mut args = std::env::args();
+  if args.len() != 2 {
+    eprintln!("Usage: advent input");
+  }
+  let _ = args.next();
+  let filename = args.next().unwrap();
+
+  let input = advent_lib::read_lines_file(&filename)?;
+
+  let mut tile_flips: BTreeSet<(isize,isize)> = BTreeSet::new();
+  for line in &input {
+    let mut x: isize = 0;
+    let mut y: isize = 0;
+    let mut c_iter = line.chars();
+    loop {
+      match c_iter.next() {
+        Some('e') => {
+          let (new_x, new_y) = adjacent_cell(x, y, Dir::East);
+          x = new_x;
+          y = new_y
+          //x += 2;
+        },
+        Some('w') => {
+          let (new_x, new_y) = adjacent_cell(x, y, Dir::West);
+          x = new_x;
+          y = new_y
+          //x -= 2;
+        },
+        Some('n') => {
+          match c_iter.next() {
+            Some('e') => {
+              let (new_x, new_y) = adjacent_cell(x, y, Dir::Northeast);
+              x = new_x;
+              y = new_y
+              /*
+              if x % 2 != 0 {
+                y += 1;
+              }
+              x += 1;
+              */
+            },
+            Some('w') => {
+              let (new_x, new_y) = adjacent_cell(x, y, Dir::Northwest);
+              x = new_x;
+              y = new_y
+              /*
+              if x % 2 != 0 {
+                y += 1;
+              }
+              x -= 1;
+              */
+            },
+            _ => { },
+          }
+        },
+        Some('s') => {
+          match c_iter.next() {
+            Some('e') => {
+              let (new_x, new_y) = adjacent_cell(x, y, Dir::Southeast);
+              x = new_x;
+              y = new_y
+              /*
+              if x % 2 == 0 {
+                y -= 1;
+              }
+              x += 1;
+              */
+            },
+            Some('w') => {
+              let (new_x, new_y) = adjacent_cell(x, y, Dir::Southwest);
+              x = new_x;
+              y = new_y
+              /*
+              if x % 2 == 0 {
+                y -= 1;
+              }
+              x -= 1;
+              */
+            },
+            _ => { },
+          }
+        },
+        None => break,
+        _ => { },
+      }
+    }
+
+    if !tile_flips.contains(&(x, y)) {
+      tile_flips.insert((x, y));
+    } else {
+      tile_flips.remove(&(x, y));
+    }
+  }
+
+  println!("{}", tile_flips.len());
+
+  let mut state = tile_flips.clone();
+  for _ in 0 .. 100 {
+    state = iterate(state);
+  }
+
+  println!("{}", state.len());
+
+  Ok(())
+}
+
+
+fn iterate(input_state: BTreeSet<(isize, isize)>) -> BTreeSet<(isize, isize)> {
+  let mut min_x = 0;
+  let mut min_y = 0;
+  let mut max_x = 0;
+  let mut max_y = 0;
+
+  for (x, y) in &input_state {
+    if *x > max_x {
+      max_x = *x;
+    }
+    if *x < min_x {
+      min_x = *x;
+    }
+    if *y > max_y {
+      max_y = *y;
+    }
+    if *y < min_y {
+      min_y = *y;
+    }
+  }
+
+  max_x += 2;
+  min_x -= 2;
+  max_y += 1;
+  min_y -= 1;
+
+  let mut output_state: BTreeSet<(isize,isize)> = BTreeSet::new();
+
+  for y in min_y .. max_y + 1 {
+    for x in min_x .. max_x + 1 {
+      let mut adjacent_count = 0;
+      for direction in &[Dir::East, Dir::West, Dir::Northeast, Dir::Northwest,
+                         Dir::Southeast, Dir::Southwest]
+      {
+        let adjacent_coordinates = adjacent_cell(x, y, *direction);
+        if input_state.contains(&adjacent_coordinates) {
+          adjacent_count += 1;
+        }
+      }
+
+      if input_state.contains(&(x, y)) {
+        if adjacent_count >= 1 && adjacent_count <= 2 {
+          output_state.insert((x, y));
+        }
+      } else {
+        if adjacent_count == 2 {
+          output_state.insert((x, y));
+        }
+      }
+    }
+  }
+
+  output_state
+}
+
+
+fn adjacent_cell(x: isize, y: isize, direction: Dir) -> (isize, isize) {
+  match direction {
+    Dir::East => (x + 2, y),
+    Dir::West => (x - 2, y),
+    Dir::Northeast => {
+      if x % 2 != 0 {
+        (x + 1, y + 1)
+      } else {
+        (x + 1, y)
+      }
+    },
+    Dir::Northwest => {
+      if x % 2 != 0 {
+        (x - 1, y + 1)
+      } else {
+        (x - 1, y)
+      }
+    },
+    Dir::Southeast => {
+      if x % 2 == 0 {
+        (x + 1, y - 1)
+      } else {
+        (x + 1, y)
+      }
+    },
+    Dir::Southwest => {
+      if x % 2 == 0 {
+        (x - 1, y - 1)
+      } else {
+        (x - 1, y)
+      }
+    },
+  }
+}
diff --git a/24/tests/main.rs b/24/tests/main.rs
new file mode 100644
index 0000000..4b8bde1
--- /dev/null
+++ b/24/tests/main.rs
@@ -0,0 +1,14 @@
+use assert_cmd::prelude::*;
+use std::process::Command;
+
+
+#[test]
+fn personal_input() -> Result<(), Box<dyn std::error::Error>> {
+  let mut command = Command::cargo_bin("advent_23")?;
+
+  command.arg("input");
+  command.assert().success().stdout("24798635\n12757828710\n");
+
+  Ok(())
+}
+