diff --git a/2020/day24_lobby_layout/Cargo.toml b/2020/day24_lobby_layout/Cargo.toml new file mode 100644 index 0000000..447b739 --- /dev/null +++ b/2020/day24_lobby_layout/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "day24_lobby_layout" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/2020/day24_lobby_layout/challenge.txt b/2020/day24_lobby_layout/challenge.txt new file mode 100644 index 0000000..ead891c --- /dev/null +++ b/2020/day24_lobby_layout/challenge.txt @@ -0,0 +1,47 @@ +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 *new tile floor*. + +The tiles are all *hexagonal*; they need to be arranged in a [hex grid](https://en.wikipedia.org/wiki/Hexagonal_tiling) with a very specific color pattern. Not in the mood to wait, you offer to help figure out the pattern. + +The tiles are all *white* on one side and *black* 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 *list of the tiles that need to be flipped over* (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 *reference tile* in the very center of the room. (Every line starts from the same reference tile.) + +Because the tiles are hexagonal, every tile has *six neighbors*: 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 *no delimiters*; 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 *`10`* tiles are *black*. + +Go through the renovation crew's list and determine which tiles they need to flip. After all of the instructions have been followed, *how many tiles are left with the black side up?* + +To begin, [get your puzzle input](24/input). + +Answer: \ No newline at end of file diff --git a/2020/day24_lobby_layout/src/lib.rs b/2020/day24_lobby_layout/src/lib.rs new file mode 100644 index 0000000..91619dc --- /dev/null +++ b/2020/day24_lobby_layout/src/lib.rs @@ -0,0 +1,139 @@ +use core::fmt::Display; +use std::collections::HashSet; + +#[derive(Debug, PartialEq, Eq)] +pub enum ParseError { + LineMalformed(String), +} + +impl Display for ParseError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::LineMalformed(v) => write!(f, "Line is malformed: {v}"), + } + } +} + +#[derive(Hash, PartialEq, Eq, Clone, Copy)] +struct Position { + north: isize, + east: isize, +} + +impl TryFrom<&str> for Position { + type Error = ParseError; + + fn try_from(value: &str) -> Result { + let mut north = 0; + let mut east = 0; + + let line = value.as_bytes(); + let mut idx = 0; + while idx < line.len() { + match line[idx] { + b'e' => east += 2, + b'w' => east -= 2, + b'n' => { + north += 1; + idx += 1; + match line[idx] { + b'e' => east += 1, + b'w' => east -= 1, + _ => return Err(Self::Error::LineMalformed(value.to_string())), + } + }, + b's' => { + north -= 1; + idx += 1; + match line[idx] { + b'e' => east += 1, + b'w' => east -= 1, + _ => return Err(Self::Error::LineMalformed(value.to_string())), + } + }, + _ => return Err(Self::Error::LineMalformed(value.to_string())), + } + idx += 1; + } + + Ok(Self { north, east, }) + } +} + +impl Position { + fn get_neighbours(&self) -> [Self; 6] { + [ + Self {north: self.north, east: self.east+2}, // E + Self {north: self.north, east: self.east-2}, // W + Self {north: self.north+1, east: self.east+1}, // NE + Self {north: self.north+1, east: self.east-1}, // NW + Self {north: self.north-1, east: self.east+1}, // SE + Self {north: self.north-1, east: self.east-1}, // SW + ] + } +} + +pub fn run(input: &str) -> Result<(usize, usize), ParseError> { + let mut flipped = set_pattern(input)?; + let first = flipped.len(); + + for _ in 0..100 { + apply_rules(&mut flipped); + } + + let second = flipped.len(); + Ok((first, second)) +} + +fn set_pattern(input: &str) -> Result, ParseError> { + let mut flipped = HashSet::new(); + for line in input.lines() { + let pos = Position::try_from(line)?; + if flipped.contains(&pos) { + flipped.remove(&pos); + } else { + flipped.insert(pos); + } + } + Ok(flipped) +} + +fn apply_rules(flipped: &mut HashSet) { + let mut new = HashSet::new(); + + flipped.iter().for_each(|tile| { + let neighbours = tile.get_neighbours(); + if (1..=2).contains(&neighbours.iter().filter(|n| flipped.contains(&n)).count()) { + new.insert(*tile); + } + neighbours.iter().for_each(|neighbour| { + if neighbour.get_neighbours().iter().filter(|nn| flipped.contains(&nn)).count() == 2 { + new.insert(*neighbour); + } + }); + }); + + std::mem::swap(&mut new, flipped); +} + +#[cfg(test)] +mod tests { + use super::*; + use std::fs::read_to_string; + + fn read_file(name: &str) -> String { + read_to_string(name).expect(&format!("Unable to read file: {name}")[..]).trim().to_string() + } + + #[test] + fn test_sample() { + let sample_input = read_file("tests/sample_input"); + assert_eq!(run(&sample_input), Ok((10, 2208))); + } + + #[test] + fn test_challenge() { + let challenge_input = read_file("tests/challenge_input"); + assert_eq!(run(&challenge_input), Ok((427, 3837))); + } +} diff --git a/2020/day24_lobby_layout/tests/challenge_input b/2020/day24_lobby_layout/tests/challenge_input new file mode 100644 index 0000000..58e6158 --- /dev/null +++ b/2020/day24_lobby_layout/tests/challenge_input @@ -0,0 +1,481 @@ +seweswweswnwseeeesenwneseeseee +wwswwwnewnenwsweneswwwwwseww +eneneeesweeneneeeswnene +nenwswwsenenwnwnenenenenwnesenwnenenenenene +eneeenwneseneeseseseswsewswseswsenwe +eeneneenenwneseneesweneene +wwwwnenenwwwwwswsww +wnwnwenwnwnwnwnenwwwnwnwnwseswnwnenw +sewsweswnwnweswswnwswe +swenwnwnenwnwnweneeswsenwswneswneswsew +seswsweseswneswswneswnwsenwswsenwswsesenw +swsenesewswnenwnewseswseenwnweseseseew +senwseswseswnwswswswseseeseseseswswesw +eeeeneeenweneeeeneesweenewwne +sewnwnwnwnwnwnwnwswnwwnenwnwnwnwnwnwnwe +swenenwneenwwnwwenwwnwwenwseswswnwe +seswseseeseswnwswswse +nenenenwswnenenenenene +wnwseswwwnwwswwswswseswnewwswseww +seeswwnenewwnwswsenewwswwwswswsww +wnesewnwwnwnenwwewsewnwneeseseswwnw +nesewsesesesesesewsweseseseseewnwsw +swswswsewseeswswswswswneswswwsewsesenesw +nesewswwwswswwwwswswwsewnwswnesew +seseesweswnweeswseenwnenweenwwe +swswnweswnwswswswseswseswswswsesesww +nwenenwsenenwnwnenenwneneneneneneneswnesw +eenwewnwsesweesesenwnewnwnwsenesw +wswswswneseseseswse +nwnwnwnwnwenwnwnwwnwsenwnwnenwnwnenew +swsesesewseeseseseseneeseenwesesesese +neseneswsenewsesenwwwswswsenweswnee +swswnwwswsweswswswwswswwwneswwswsw +swswswnewwswswnesweswwswwswnwwwww +neeesewnwnenweswswnwswsenenenwsenwsene +nwnwswnwswenwwwnwwenweenwwnwnww +neswswnwswsenwwswswsweswseswsw +neweeneneseeweeeseeeneswnweene +swenwneswsewswneswwnwswnwswswswswswwe +nenwswneswnenwsenwnenwsew +nwnwnwnenwnwswwnwnwnwneswsenenwnenenwnwnw +wseswsewnewseswswnweseseneswswnenenwse +neeeeeswneneneneneneeneeswnwnwneee +eneswneenwnenwsewswseeeenwseseew +swswswsewseeswenwseenwseswswswseswnwswse +seseeseewseseeseswsesenenwseseseeenee +neswswswswswswnwwswswwswswsewswnesww +wsenenwneneneswnwnwnenenenwnenwnenenwnw +wnwsenesenwwswsewsweenwwwwwswsw +swnwneseswseswnwswsewseswswseswswsweeswsw +seswswswnwneswswwnwswseswnwseswswswenesw +nwnwnwnwnwsenwnwnwwenwnw +nweeeeeeeeeeeswseenewsewne +neneneneseneeesenewwnwenewneneswne +nwwnwnwnwnwnwnwwwwsenwewnw +nwswnenenwneneseneneseenwnwnwnenwne +seneneneneeeenwsenenwsweeneeenenene +wnwwnwwnwswwswwnwnwnenwwwnwnwne +swwenewswwweewswswwswnwswswnwsw +newneswsenenwsenenwswesenwnwnwnenwnenese +neneswneweneneneeneneeeeeneesenw +seweseswsewsenwesenenwsese +newewseneesweswseneswnenewwsenwe +nesenwsewnwnwseswnwswsenenwewwnwsene +nwnewwsenewwnesewwse +swswesweneneneswenwswnenenesenewnee +swnwseenwnewneneseewne +nwwwnwnwenwnwwnwnwnwnw +eseseneswneseswsesenwwwsewnesesesee +nenwnwnwnwnwnwnwnwnwnenenwnwnesewsenesw +nenenenenenwneneswswnenenwwnwneneneenw +seswseswneewneswwseseswseseswswseswswse +wsewneseeseseseseneswsesesenesese +sweswswwswswswswswswswwneesweeww +neswswnwswswswswwswswsweseeswswswewsw +nwneenesenwswenenesenwswnenenewsenene +eweeeeeneeseesenwesweeeeee +wseeenwnweeswnesweeneeenenwseee +esenwseseesenwwseeeeeeeseesee +wwwnewwwswwsewwwewnewwwnwwse +swswseswseswsenwswswnwseswseswesenwese +senwseseseseenwseeseseseseeseswsesese +wewnewwswnwwnewnwswswseewwsww +wswswswswswwswswnwweeswwwwwww +eeenweewenesweeeeeseee +swwswesewswsenewwneswwwswwneeww +nwnwnenenwseneseenenwnenwnenwnenwswnenw +swwswsweeswwswwswwswneswwwnesesesw +nwneswneneneneneenwneneswnenenenenwnenw +nwwwswsewesenwwsweneswnenwseswwsw +sesesesewseneseseseseseesewsewsesesene +nenwneeswswswsewswnwnwwswneswsenew +senenwnwswnwswesewswnwnwnwnweenwneneswse +esewweeeeesenwneeseesweeeene +newwseseeseeseseseseseenwewsesese +seneseeeswweeesewneseseewseene +swseeseseeseswsewnweneswnwenesewnwse +eweneeewesenwneeneenewenesesw +wswnwneseswswnenenenwenenenewneneenw +seeneswsesewseseswnesenwseswswnwsesese +seewesewewsenewneneneswsenwesese +senwnwnwsewnwnwnwswnewnwnwenwnenenwswnwnw +swnwnwnenwwwsenwnenwnwnwnwenwwesewnwnw +seswswneswswswswswswwswneseswswwswswswsw +neseneswnenwwnenenwnwwnesenwnenwnenene +nwseseswswwswsewseswenwnwweeswesese +seneswswswseenweewswnewswwswnwswswne +sesenwswneeenwswseswswneewnenwneswe +ewewwwwwswwnwswwwnwewwww +swnenewesewwwswwsewwnwswwnwnene +wswnwsenwnwswenwnwenwnweswwwneee +weenewswswewnwnweesewnwsweswwsw +eeseeeseeeweeeseneeee +wnwenwnwnwenwnwnwnwnwswweneneswswnee +seseseswsewnwsewseeesenwseseswesese +weweesweeneeneeseeeweeseee +swseneesweenwneswnenwneewwwswswsw +nesewwenesenenwneneeneneneese +esesenewnwnweseseweeeeeeeswsw +nwswwwneswswseeswswnwswswnewsenwswesw +weeeseeseseseesesewnesenweeese +sewsesewnesesesesewneseeenesenwesese +swsesesenesenwsesewseseswseswseseswswse +neswswswwswswswswwswswswswswsw +nwnwnwnwnwnenwnwnwnwsenwnewnenw +seneneenwnwnwneswnwnwnenwnwnwnwnwnwnenw +swnweeeeeeeesew +neseswwnweeeeswseeseeeseeeswene +eeneeeseeneeseeeeewneeenwsw +senwswseesesesesweeenwseee +wwwwswwwsewswswswnewwswneswwsew +eseeneseeseswwseeweeeeneeee +wwnewwwwwwswwswwwewwwnewsew +sewwneeeeeesweeswenesesweneee +nenwnwenwnwswnwnwwswnww +swswseneswswesesenwsesewseswsesesesesenw +seeseseenwweseseseneeseeeeseese +newnenwseswwnwwwwnw +swwnewewwwwwwwwsewwwnwwwnw +swwnwnwnwswenwnwneenw +wnwnwswnenwnwweswweseswwswwewsw +nwenwnwnenwswewswnwnwenwnwnwwnwnenw +esewseseseeeeneseseeeewsenesw +swwwswwnwwnwwweswswsewwswwnesw +senwswnenwnwneenwswnwnwneenwnwnwnenwnww +wwnwwwwwwnewewwwwwsenwswsww +nwnwnwnwnwsewnwnwnwnwnw +swnweseswseseswenwwseneseneswnweswswsw +enenenewseseneseeeneneeneenenwnwne +neneneewwenesenenenenwneneneneneene +neeeneeeneneweeeneee +neseeswswswnwswwswswwswswnwswwswswsw +wwwnenewwnweseseswsenewnwnwnwwse +swwwwsewswswswswswswswwsweneswsw +seneseeseswsesesesesewseseseswsenw +nwwwwnwnwwnwsenwwwwww +wwwwwswnewewseneseswnewswwseewnw +neswnweeswneewwneeeeeneneenenese +neneeneewewsesewnwseeene +seneneneenwnwnwnwnenwnwnenwnwnenwnwswwe +wswswwwseswneswwswwsw +nenwnwesewneneewwwseswwsw +wnewnwwwwwnwnwewwwwswewseww +seeeeseenwsenweswsesesesenwseseee +nenwwsenenwnwnenwnenwnenenesenwnwnwnwnw +wwnwsewwswnewwswewwwwwwsww +seseseeeeseesenwseseseseseese +nweseseseswenesesesesewseseseseseneese +nwswswswwswsweswwsweswswswswswneswsw +wwwsewwwsewwwwwnwwenewnww +nwwnwwwwnwwsesenenwnwwwnwnwwwnw +newnewsewswneenesenenenenenwnesenwe +wnwswswnwwenwnweenwnwewnw +newnenesweneseenenenee +nesweneneneneseewneweeweewswee +wwwwswwwwwwwewww +nwnwsweswwnwnewnwnwnwnenwswwnwneswnw +esenesewswswswswswseswseseswswsw +nwnenenwwnesenenesweneswnenenenesenene +swwewnwwnewwwweswnwsewwnwnenw +swwwneseweseswwswneneswneneseswswnesw +nenwwneneneswnenenenenwnenenenesenw +swswswswseswswnwswseswswsw +swswswsweseswswswwswswswswneswswwsww +neseswseswseswswneneswswsewwswneswswsw +swwswwswwwswnwwwwwwswesww +swswsesewnwswswswseseseswswswne +nwseswswswswswseswseswse +sesewwsesewseesenesenwwseseesesesee +swnwwswswswsweswswwswswswswswswsw +nwnenenwnwnwsenenwwnwsenwseewnwesenww +wwswnwwwwenwwwwwnwsenewewwne +wsenesenwwnesenesenww +eeeeeswnwseseeeseneswenwsewswsee +swwwewwwewwswwwswnw +eeneswnweeswseeenwseeswnwweseee +nenwnwswneenenenwwnenwswneneneneneeenwsw +seseseswneesewwsenwseseesese +newnenenenwneseneenewnenenenesenenenenw +nenwswweseeswsenwsenwsewneswseneswnw +eeneewsenweeeneesewee +nwwnwwsewnwwwwwnwnenwsenweww +neneneswnewnenwneneswnenenenenenenwnesene +seseeseseswseesesenwseseswswsesenwsww +seeswnenwswwnenesenenwnwnwnenenenenene +wneneneswnenenwnwwee +newswwwwsewnwseswneenwwseewnewne +swswwwwswneeswwweseswnew +swnwseeseeewesweneeswenwswwwne +eweseeeeeeeeeenweseeeeenw +wwnwwsenewwwwwwnwnewseswswwsew +neeseseeeesesesesesesesenwsewsesew +nwnenwnenenenenwnwnenenenenenwenenesesw +senenenwnenenenenenewneneneene +senwseswwseswswseseneswswswswsenwseee +nenwwnesenenwseswsenewnenwswnenese +nenwnwnwsenwnwnwwwnwnwwwwnwwnw +seseeswsenwneeeesewwsenesenenwsewse +eeseeesenwseesweeewenwsesesee +eswnwnwwsenwnwnwwnwwne +swswsesenwswseswswswesw +nwwnwwnwnwnwnwnwnwse +newsesenwnwsewsenenewwse +swnwnwwsenwnwnenenwnwnenwnw +swswwnewewwsesenewnwseswswswswswsw +eeeneseeeseseeseeeweseese +neneneneneneseswenweseneweenewnwene +nwnwwnwnwnwnwnwnwwnwnwnwnwnwesenwnenw +senenenewswseeenwswesweeneene +nwnwnwenwnwnwnewsenwnwnenwsenenenwnwwnw +nwswswswseswswnwswswseswesenwswswswseseswsw +senwwnesenwswseseswseseswenwswesesee +weeseeeeseenee +nwnenwnwswnwnwnwnweswnenwswsee +wwwnewwwnwewneswneswnwswwsenwnww +wseswneeseseswenwsesenwnenewse +seneenwswnewneneeeeneeeneneneenenwne +sweneweeseeeseeeneewseee +eswseseenwsesesesewseenenwswnwseeswse +swneswwnwwwwwwseswwswwswswwsene +sesenesewswsesenesesesesesesesesesesese +weneweswewseseeeeneeseeenee +seeseeseenesweseesweeeeswneenwe +weseewnweeeswseseeeswswnewsenene +nenesenenenwnwnenesenenenwnenwwnwnwnenesew +nwweeeeeeeeeeseeseee +neswnenenenwnenenenwnwnwnwnenwne +neneenweeeswwseeswswenweweswnenw +wnwnwnwswewnwwwnewwnewnwwsenwnw +seeswseseswnewnwsesesesesesesesenewnwse +wnewsewewwwnwnwweeswwwnwswnw +seeseeseeeeeeeeeeenwweneew +eeeeseenwsweesenwnweeesenwswee +swwswnwseswswswswswswsweneswswswswswsw +nwnenwwnwwnwenwnwnwsenwnwnwnwwnwnww +swnewneneenewnenwswnwsenewnwneesee +wwwwwsewwwwnwnewnwwnenwseswnw +swsewweweswwwswnwwewwnewwwe +wnwenwswswwwwwwwwwwswewwne +nenenenenenenenenenenesesenenwnenwwnenwe +nwnenwenwenwwnwsenwnwnwwsenwnwnwwnwnw +seswnwnenwenwseswwenesenewneswnwnwnene +enenenwswnwnwnwnenenesenwnwsenwwnwnwnw +swsewwsewseenwnwnewnwwwnwnwnewse +seseswnwswswswswwseswne +nwwnwsewnwnwnwnwnwnwnwnwnwenwnwswnwnwe +swnenenesesenenenenwnenenewnesewneenene +seswsewswseseswseswswswnewneseswseswse +nwsewsenwnwnwwnwnwwswnewnenwwsewwwnw +seeeeseneswnwneenenwnenwneesenwe +wwneeenewseeesesesesweeesesese +swwswswsewseswswneneewneeswnwsesewe +nwneswswswsweswseswswswswseswswswnewswsw +nwnwwsenwwnwnwnwnwwwwnwnwenwsenwww +neenwswnwneenwnwwnwnenwnwswnwswnwnwe +nwswnwnwnwwnwswnwnwnwnwswneewnwnwnwnwenw +swswneseswseeeeeeseseneseesenwsewe +neseesesesewseweeweeneswseeeene +swseeswsesewswswseseeswseswnwsenwswnese +swwswwswsewswwswnwswseswwnenwswsww +nwneewnwnwnwnwwnwnwnwnwseswwnenwnwnwse +nwnwenenwnwnwnwwwenenewneswe +eseeneeneneeseneweenweneeewsw +wswswswsewswswnewweswnewwwswwwsw +newnenenwenenenenwnene +swwnwwswwwswwwenwwwewwwswwsw +neneeneneswwneneenenwseneeneneneeenwne +newnwswsweswseseswnwnwswswswseseswnee +eneeneeneweneneneswnweneesenenene +sweeeswnwneeneneenweeeneesw +neswsenwesesesesweseseweseseeeese +nwseswnwnwswneneenwnwnwwwnenesenenwnenw +sweeeeseeneesweseesenwneesweee +wwswneesewnwseseeeeweswesewsww +sesweswswseeswswsenwswswswwseswneswsesww +swneneneeseneenewnew +sesewsesenwnwesesesewseeeseswsesesese +swseswseswswewswnenwswneenwnwneswne +neneneneneneneneswenenenenwsw +weswwnwwwnwwswswnwnwewweeenwnw +wnwwwwwnwwswwnwnwsewnwwnwwwewe +nwwswwswnwneswsewseeswseseswnewnenwnesw +nwnwnweswsenwsenwswnesenwwnwsenwswee +nwwneseswswweseswseswswnenewseswswnww +eeesweneenwneeeneneswesewneswneene +weeneswswewseeeeeeenwneee +nwnwnwenwnwnwnwwwnwsewsewwwnenwnw +neenenwwneneeswseneswnewnene +enwnwnwnwnwnwnwnwnwenwsenwnwwswnwnwnwnwnw +wnwswseseneseseseswsesesewsenweeseew +swnweswnesenesewseneseseseenweeseew +nwseeeseseeseesesenwswneseseweseesw +wwwswwswneswwwwweww +seswwenwseneewneeneeswneneeswnwnew +nwswseswwwneswswswswwnwseswswesweswsw +sewswwwwswswsenwsenewwwwwwnwsww +nenenenenenwswnenenenenenenene +seseneseseesenwswsewseswswseseseswseseese +swwnesewnwseneswnenesweeeneswewne +nwnwnwwwnwwnwwnwnwswewenwnwnwnwnw +nwnwnwswwnwwsesenwnwwnwsenwenweneswnwnw +seswseeswnwseseswseswseswseseswseseswnw +swswsweswswsenewneswswsenwwswswswswe +sweswswswwwswswwnewwswnewswswnesw +weseseswswseseswsese +wnwwnwwwwwwwewwnwnw +neseeeseeswnwwnesee +nenesewswnesenenenwwnwnenweseeswwenw +seseseneswwsewnwweeeewnesesesesese +seswnewnwsenwswseseswsenwseesesesesesesese +neneneswnenwnwnesenenenenwnenesenesenenene +swneswswnewsenesweswseswwseswswswswsesw +nwnwneswsweeeneeneeeneneesenwnenene +senwnwswnwnweswwnwsenwswnwnesenwswwee +eneseswenwneseswneesenwwneeweewwsw +seewswswswenwnwwwnwnwnwwnwnwwnwne +eneenwnewswnwnewsewseneeswnwenesww +nenesenenenenwnesesenesewnenwnenwwnenese +eenesewsweeeweseweeeseneseee +weneeseesenesesesesesesesewesesee +swswwswwwswwwswnwswwnesweswwneswwsw +neswneseneneewnenenwsenwnenewneneenew +neseeswsweswwseeneenenewwnenwene +eeeneeneeeeweeeeee +nwenwwwwnwwwwwwwnw +nwswnwnwnwnwwnwnwnwnwsenwsewenwnwnwnw +swseneneneswnenenwnenenwneneswnenenenee +nenwnenwsenwnwnwwnwnenwnene +eeneeeeneeeeeeenesw +esweeeweseeeneneeenwseeswnwswswne +nenenenwnesenwnenenwnenenenenene +swnwewswwswnwswwswswnesweswswswwse +wenwneneenesweeneneeeeseneenenwe +nwnewnwnwenwswswnwnenwsenwee +wswnwesenwwswswewneswwweweswwnenw +seweswneeswneswneneeneneneneenewnesee +nenwnwnewneeneeeesweneneswneneswne +nenwenenenenenesweneneneeenenewee +nesenwneneneneneneseneswnwnenenenwnewse +wnwwsesewsewwswwneswneswwnewswww +nwnwsenenwnwnwnwnwwwenenwwwwswwww +neeseeeseseeseeseeesw +neneneswnwneneseneswwneseeneewne +nwswsewwswswewwwwwwwwwnwswsw +swswseseneseesenesenwswsesesesese +eenwwseswwwswsweeswswswswswswsese +eswneswswswswswnewwswswswweswenwe +nwseseswseswswseseseseseswnwseseneswsesw +swseeswenwseeeeseseneseseeeesenee +seeseswwwsesewseseseseseeeenwesee +seswswseseseseseseseeswenwswswswnwsesenese +nwnwwnwsenwwnwnwnwwnwnwnw +nenwnwswnwnweswnwnwenenwneeneswnwnenw +neenewneneneneeneenenwewnesenenene +swswwwnwwnenwswsesewsewww +nwnwnwwneeswswnwesenwnwsewnwwenwnwsww +wsewwwnenwsewwwsewwnewnwwsww +neeneneesweswneeewsweneneenenwenee +nwnewneeneneeseswesewenwneswneewe +wswwnewswswswswneswswswwwswsw +nwwwneneswsenewnwneeeswsweneswenwe +wswswswwswnenewewswswswwnwswseswsewsw +newwnwnwnwnenwnweswnenwnenwnwsenenene +nenwnenenenenenenwwnweneswnenenwsesenew +sesenwnewnwnwnwswsweswnwswwwwsewsee +wnwnwsenwnwnwnwnwenenwseeswnenwswnwsesw +nwnwwnwnwnenwsenwnwswnwenwswnwwenwnw +eeeeseseseeeeeweseneweesee +eswesewenweneeneeseseeseeeee +enenewnenenenenesweswnewnesenenenenenene +swnweeenwnenwnwewneswnewwswwenw +sweswseeesweeeeneeseeeeeneesenw +wnwnwswnwnenwnwnwnwnwneswnweswnwnenenw +swswswswswswwswwnwswsweswswewswwsw +nwenwnewwnwswwnwnwesenwsesenewnwnwnw +wwswwwwwwwwsenw +swwnwsewwnewwnwswnwnewwnwnwnwne +eeeesenweeenenenenweeeeswe +enesweswswewswswseswnwswnw +eswseswnwsenwsewesenenewwwseesenwse +sesewwnewwnewwwewwwnwswnwwww +nenenewnenenenenesenenenenenenenene +nenwnenenwnenwnewnwnenesenenwneswnwnwswne +seseeswnwnwseswsesewseeseseesewesenw +swsenewsewswseneseseeeeseswnweenwse +eswwnwwwewwswne +sewseneewswswseswwseeseswewseswnw +wswwwwwsewwwwwwwwwnwsenew +wnwnenenwswwwwewswsewwwesenwe +wweewnwnwsesenwwewnwwwwwsww +neenwneneeswnwnwneseenesene +nenwsenewnwnenwneswnenenwenwwne +neeseneenwneseenwseenewneswneenesew +nwnwnewnwnwwneswenwnwnwwnwsenwsenwwnw +neneweneseneewwswwnwnwsenwnewnenesene +nwnwnwnwnwnwnwnwnwwswenewnwnwnwenwnesw +weseeneeneeeeseeesesenwnwswswese +senenesewnenenwnenenenewnenenenene +wnwsenwnwwsenwnewwnwenwwwnwnwnww +enwnwnwnwnwsweswnwsenwnwwneneswwnwe +eswnenenwneneweneneeneenenenenwswe +nesesewseswseseeseswsesenesesesesenese +swnwneswnenenwswesweeesweewnweenwsw +swnwnwswswswwseneewwneewswwswswsw +ewnwswnenwwwswnwsenwnwnwnwwwwwnewnw +seseseseseeeesenw +nwnwwnwswwenwwnwnwnwnwswnwnwnwenwnwnw +nenwnenenenesenwnwswnwneneswnwenenwneese +wnwwwwswwewewwwwswnewwwsww +nwswsewswwswneswswnewswwswseswnwww +neenewneneneswenwwnewnwnwnenwsesenw +seseesesesesesesesesweswwsenwsesesese +nwewnwswneseseseewsesenwseseseeseese +ewneeeeeeesweewenewse +wnwwwwwwwwnwnwwsenenwwwwenw +wseswswswswwnenenwwewenwswnew +nenwsenenwnwnwnwnwwnwnwnw +wneeneenenenwsesewnewwsenenwswswsw +eeeeenweeswewsweeeeeenwee +wenwseswseswswnwswswswswneswseswseee +nenenwnwwenwnwnwnwnwnwnwnw +wsewwwnwnewwwwwwwwsewwww +wwwwswnwwswwswewenwswwwwnwswwse +seneswwwwewnewwwwswwswwswwwe +nesewswneswswnwwwsewwwwswswwnesw +swewseswnwnwswweseeswwswnwnweswsw +nwnwnwenwnwswwsenewswnwnwnwnweenwnwsw +swenwswswseswswswswswswswswwswseseese +nwseswnwneswwswwnweeswewnwnwwwew +nwseswwnwenwewwnwnwswwnwnwnwnwseww +enweneeeeeeeenwsweesweew +nesenenwnwwwnwwswnwnwnwwnwwse +weneeeseseneeenweeeneneenwewe +senwnwnwnwswneneswnwnwnewnwsenwwnesee +nwneseneswnenenwnwnwwnw +wnwnwwswnwnwnwnwesewnwnwswnwnwwnwnenwe +nwswwswswwseewsweseswneeneseesew +enwwnwwswwswenwwsweenwnwewnwse +seewwwswnwwswwwwswswewwswswwnw +nenwnenwneenwsenenewnwwnenwnwnenwnw +swswseseswswswneswswswswswswsesweswsenwsene +neneneswswneneseneweswnenwseswseswwsw +wwweneswwwwwswsenew +swswswnwseswswswswswswswsw +nwnenesenenwnenwnwnwnw +eeesenwseeswseeeenwneswseeenwsenew +seeeeseseeswsesenweeeewsewsese +swseneswswseneswnwswswseseswseseswwsewsesw +nwswnenenwneenwsenwswnwnenenwnwnwsenenwsw +nwseseeeenwswswnwswese +nweneneenenwsenenenenese +wswswswwwwewwwneswwesewneswwswnw +nwsenwwnenwnenwsenewnwnwnesenenenwnwne +nenwswnwenwseswnenwwnwnwnwnwwenwnenenw +wseswweswenenwswwswseneewwwnew +seeswseseesewenenwswewe +swswwswswsenenwneswseswswswswswswswswsw +wnwsewsenenenwnwsewnwwenenwswnwnwsenw +seneeseeneswsesenweseswweeswsenwswe +nenenenwnwneenewesesenenenenewsenenene +eneeneeeeeeeeseenew diff --git a/2020/day24_lobby_layout/tests/sample_input b/2020/day24_lobby_layout/tests/sample_input new file mode 100644 index 0000000..3dc2f67 --- /dev/null +++ b/2020/day24_lobby_layout/tests/sample_input @@ -0,0 +1,20 @@ +sesenwnenenewseeswwswswwnenewsewsw +neeenesenwnwwswnenewnwwsewnenwseswesw +seswneswswsenwwnwse +nwnwneseeswswnenewneswwnewseswneseene +swweswneswnenwsewnwneneseenw +eesenwseswswnenwswnwnwsewwnwsene +sewnenenenesenwsewnenwwwse +wenwwweseeeweswwwnwwe +wsweesenenewnwwnwsenewsenwwsesesenwne +neeswseenwwswnwswswnw +nenwswwsewswnenenewsenwsenwnesesenew +enewnwewneswsewnwswenweswnenwsenwsw +sweneswneswneneenwnewenewwneswswnese +swwesenesewenwneswnwwneseswwne +enesenwswwswneneswsenwnewswseenwsese +wnwnesenesenenwwnenwsewesewsesesew +nenewswnwewswnenesenwnesewesw +eneswnwswnwsenenwnwnwwseeswneewsenese +neswnwewnwnwseenwseesewsenwsweewe +wseweeenwnesenwwwswnew