diff --git a/README.md b/README.md index 3120091..4b8e232 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ My (attempted) solutions to [Advent of Code 2020](https://adventofcode.com/2020) in Elixir. -image +image ## Strategy diff --git a/day24/README b/day24/README new file mode 100644 index 0000000..00c4415 --- /dev/null +++ b/day24/README @@ -0,0 +1,58 @@ +Day 24 Notes + ++--------+ +| Part 1 | ++--------+ + +$ elixir day24part1.exs +326 + +Thoughts: + +Interesting. Need to work out how to implement a hexagonal grid. + +Use Enum.chunk_while to parse the variable-length `e`, `ne`, `s', `sw` etc. input tokens. + +I decided to do it like this: Use x, y coordinates, but horizontally adjacent cells are 2 x units +apart. Diagonally adjacent cells are 1 x unit and 1 y unit apart. + + / \ (0,0) + | | + / \ / \ (1, -1) +| | | + \ / \ / + ↑ +(-1, -1) + +Define a tranlation vector for each direction, then we can walk the directions, and take the sum +of all the translations. + +Store the black cells in a MapSet, and count them once we're done. + ++--------+ +| Part 2 | ++--------+ + +$ elixir day24part2.exs +3979 + +Thoughts: + +More complicated now, because we actually have to iterate all the black/white cells and their +neighbours. Calculating the grid extremities looks complicated due to the hexagonal properties. +However, this is very similar to Day 17 Part 2, so I will just adapt that solution for here too: + +1. For all current black squares, check the neighbours to see what its next state should be. + - additionally keep track of which white squares we identified. +2. As white cells must have a black neighbour to be flipped, we know that it's fine to only + check white cells that are next to a black cell. So iterate the white cells we encountered + in step 1, and check their neighbours too. + + ++------------------+ +| Overall Thoughts | ++------------------+ + +Let another game of life. 3rd time this year? This one was a bit more interesting due to the +hexagonal nature, but part two was almost the same as Day 17. Maybe that's a good reflection +on my day 17 implementation, though. diff --git a/day24/day24part1.exs b/day24/day24part1.exs new file mode 100644 index 0000000..e3ef5c3 --- /dev/null +++ b/day24/day24part1.exs @@ -0,0 +1,53 @@ +defmodule Cell do + defstruct [:x, :y] +end + +defmodule Day24Part1 do + def run do + File.read!("input") + |> String.split("\n", trim: true) + |> Enum.map(&parse_line/1) + |> Enum.map(&to_cell/1) + |> Enum.reduce(MapSet.new(), fn cell, black -> + if MapSet.member?(black, cell) do + MapSet.delete(black, cell) + else + MapSet.put(black, cell) + end + end) + |> Enum.count() + |> IO.puts() + end + + def parse_line(str) do + str + |> String.graphemes() + |> Enum.chunk_while( + nil, + fn + "n", nil -> {:cont, :north} + "s", nil -> {:cont, :south} + "e", :north -> {:cont, :northeast, nil} + "e", :south -> {:cont, :southeast, nil} + "e", nil -> {:cont, :east, nil} + "w", :north -> {:cont, :northwest, nil} + "w", :south -> {:cont, :southwest, nil} + "w", nil -> {:cont, :west, nil} + end, + fn acc -> {:cont, acc} end + ) + end + + def to_cell(directions) do + Enum.reduce(directions, %Cell{x: 0, y: 0}, &move/2) + end + + def move(:east, %Cell{x: x, y: y}), do: %Cell{x: x + 2, y: y} + def move(:west, %Cell{x: x, y: y}), do: %Cell{x: x - 2, y: y} + def move(:northeast, %Cell{x: x, y: y}), do: %Cell{x: x + 1, y: y + 1} + def move(:northwest, %Cell{x: x, y: y}), do: %Cell{x: x - 1, y: y + 1} + def move(:southeast, %Cell{x: x, y: y}), do: %Cell{x: x + 1, y: y - 1} + def move(:southwest, %Cell{x: x, y: y}), do: %Cell{x: x - 1, y: y - 1} +end + +Day24Part1.run() diff --git a/day24/day24part2.exs b/day24/day24part2.exs new file mode 100644 index 0000000..ba697be --- /dev/null +++ b/day24/day24part2.exs @@ -0,0 +1,88 @@ +defmodule Cell do + defstruct [:x, :y] +end + +defmodule Day24Part2 do + def run do + File.read!("input") + |> String.split("\n", trim: true) + |> Enum.map(&parse_line/1) + |> Enum.reduce(MapSet.new(), fn cell, black -> + if MapSet.member?(black, cell) do + MapSet.delete(black, cell) + else + MapSet.put(black, cell) + end + end) + |> flip_times(100) + |> Enum.count() + |> IO.puts() + end + + def parse_line(str) do + str + |> String.graphemes() + |> Enum.chunk_while( + nil, + fn + "n", nil -> {:cont, :north} + "s", nil -> {:cont, :south} + "e", :north -> {:cont, :northeast, nil} + "e", :south -> {:cont, :southeast, nil} + "e", nil -> {:cont, :east, nil} + "w", :north -> {:cont, :northwest, nil} + "w", :south -> {:cont, :southwest, nil} + "w", nil -> {:cont, :west, nil} + end, + fn acc -> {:cont, acc} end + ) + |> Enum.reduce(%Cell{x: 0, y: 0}, &move/2) + end + + def move(:east, %Cell{x: x, y: y}), do: %Cell{x: x + 2, y: y} + def move(:west, %Cell{x: x, y: y}), do: %Cell{x: x - 2, y: y} + def move(:northeast, %Cell{x: x, y: y}), do: %Cell{x: x + 1, y: y + 1} + def move(:northwest, %Cell{x: x, y: y}), do: %Cell{x: x - 1, y: y + 1} + def move(:southeast, %Cell{x: x, y: y}), do: %Cell{x: x + 1, y: y - 1} + def move(:southwest, %Cell{x: x, y: y}), do: %Cell{x: x - 1, y: y - 1} + + # Below code adapted from Day 17 Part 2 + + def flip_times(cells, 0), do: cells + def flip_times(cells, count), do: flip_times(flip(cells), count - 1) + + def flip(cells) do + {flipped, whites} = + Enum.reduce(cells, {MapSet.new(), MapSet.new()}, fn cell, {flipped, whites} -> + {black_count, whites} = + Enum.reduce(neighbours(cell), {0, whites}, fn neighbour, {black_count, whites} -> + if MapSet.member?(cells, neighbour) do + {black_count + 1, whites} + else + {black_count, MapSet.put(whites, neighbour)} + end + end) + + flipped = + if black_count == 0 or black_count > 2, + do: flipped, + else: MapSet.put(flipped, cell) + + {flipped, whites} + end) + + Enum.reduce(whites, flipped, fn white, flipped -> + black_neighbours = + white |> neighbours() |> MapSet.new() |> MapSet.intersection(cells) |> Enum.count() + + if black_neighbours == 2, do: MapSet.put(flipped, white), else: flipped + end) + end + + def neighbours(cell) do + [:east, :west, :northeast, :northwest, :southeast, :southwest] + |> Enum.map(&move(&1, cell)) + end +end + +Day24Part2.run() diff --git a/day24/input b/day24/input new file mode 100644 index 0000000..768e585 --- /dev/null +++ b/day24/input @@ -0,0 +1,406 @@ +swsenenwwneeseswswsenwnwenewenwnwse +wnewnweswswsenewnenwnwseseweeseswne +swwnewwswswswswswswsweeswwwswnwew +seeneeenwweenwnweswwseeeee +swswseseseswsesesesenwswseswsese +seseseneswwnesenwseseswwnenwseenwsesw +nwseseswswenwnwswswneseswswseswseswswswnwse +enwsenwnewweeeswneenenwesweneswene +nwnwnwneswsenenwnwwsenwswnewnee +sesewsesenwseeseneseseseswswseswswsese +swsenwnwswnwnwneswwnwnenwwwnwnwnenwnw +eseswwwwswwwnewwwwwwswnewsww +neswenwenwswseenwseeneenweenenee +esenwnwwsenwsenenwsenwwnwnwewnwnwwnw +nwswesweseseeeeeeeesenese +neneeneesewsewswenenwswnw +seeneneewneneneneweeneswsenenenee +enwwneeeswneeenweseeeeseneenee +swwswsesesesewneseseseeseseseseseene +nwsewwweswnesewwneseeswwwenwwnw +nwnenenenwnwswswwnwwnewneenwnwsenenenwse +nwsenwnwnenwsewnenwwwnwnwnwwnwwnww +newsenewwwwwwswnwwsesenwwwwwse +senweeneeneneeneneeswnenenenewenewe +wwnwneswsewnwnenwesenenwneneneneneenene +senwnwwwnwnwnwnwnwenenwnwnwswnwnwnwsewnw +eenwnenenwseneneneswwneeeseseeseenwne +nwswewewneenwsweneeweneneneee +swwnwseswswswnweewnwwesw +wnwwwwwwwwewwwnw +swnenwswnenenwnwnwsewnenwnenenwnwsenenw +ewwswswswneswnwwswwwsewwwnwwswsw +wwseswneswwwwneswwesenwwwww +neswswwenwswswswnwswseswswswswswswewswsw +nwswnwswswswswswswseeswswwswswswswswesw +senwwswwnwnenesesewwnenwswwnewwwse +neneneneeneswsweeneneneneswneeenwsenw +swnwneswswwseswswswswswswsweswwsww +wsenewewenwwwwnwsenwnweww +swnwswswsenwswswnwswswswswsesweswsweesw +nenenwnenenenenenwneneswsewnwnwnwsenwnee +eseeswnwseneseenweeesenwweenwnwsw +eeeswnenenewenenenewneneeeneeese +swswswnwseeseswswseseseenwswswse +swseneseesewnwwnwsenwnewnewneseww +swwwnewwwsenwwnwswwewnenwnesww +swseewseeeseeesenwsenesenweeeswe +nwnwnwnwweswnwnwnwnwwswnwnwnwnwe +nwwnenwnwwnwnwswsenwnwnwwsenesenwnwne +seeseseeswseneeeseeseneenweesw +wneswnwswnenenenenwnenenenenesenenwnwnw +eseseseswewseseweeneeeeswneese +nesenenenenenwswnenenwnenwneswnenenenene +nwwnwsenwnwnwwnwwnwnwnwesewesenenwnwnw +nwnewnwseweneswnwwnw +senenesenwneewswewnenenwnenenenwnwne +eswwseswwswnwswswwwswswnewswswswsw +nenenenwneenenesenwsweseneesweeneene +wseneneenewnenenesewnweweneneesw +eeeeesenweweeeeneeswnewewene +nwneneeswwneseeswneneneneenenenenwnwsee +neswseneneenewnewwesweswnee +senwweneswwwsenenewnenwseewwsesww +nwseneeenwnewsweeeneeeeenenee +nwsewnwesweswenwseswneseesese +swseneswnwneneseseswswswswswswswswswswsewse +nwseneseeseswswswseswesesewswsewwne +enwseewsesenwsewnewwnenenenenenwsw +swnwwswsenwewswswwsw +wwewwwwnwwwnwwewwwwsw +nwnewnwnwwnwnwneswnwnwneswsenww +wswnewwwswswswwwnewweswwswwse +swnwweesenewwnesenesenenwwseneene +nwnenwwesenwsewnenwnwwnwnwnwsenw +newnwwnwsenwnwnwsewwnewwsewwsew +swneseswswswsweswswswwswswsenenewswswsw +swsweseswswseseswnweseswwnesesesesesenwsw +neneneneneswneeneeewnenewneene +sewsenwneswewwnewswwswswwwwswwww +eweeeseeesesesesenwese +wnwseswnewseneenwweneeswweeesene +sesewseseseesesesenwsweesese +ewnwnwsesenwnesewewswnwnwneswnwwww +nwwwnenesewnwnwwwnwwwsww +neswwwnenwseewsesweseeene +seseswesenwswseswsese +senwweseseseseseswnwseswswswsweeswse +swwswswwwwsenenewwweswwnwswswesw +eeeenwneenwnewswnenenewswnenenee +swwnewswswswswneswswswwsw +seeswnewswwwseeenwwswswnew +wnwswswswswswneseswswswswwswnesweswswswsw +nenwnenwnwnwnwneswnwnwneseneeneswnwwne +swneneeeeeesweeeswenweeneenee +seseneswnwsweswseswseswsenwse +swewewnweeswwswwewsewnwnwnew +eeeeweeneeeeeneeneseneswesw +wwswwnewwwswwsewnwe +wswswwnwswsweswseswsewwsenwnwwnenene +neeeeswnewseesesweeseseeneesee +nwnwnwnwnwsenenwwnwnwnwwnwnwnenwnwesenw +swseseswneswseswnwseswswswsese +wwswwwwnwnwnenwnesenwswwnwswnwnenw +wwswswseswwswwswswwwne +nwnwnwnwwnwseneesewnwnwswweneewesw +nesesweeeneeeseseneseseswwseeesese +eesweeseenwweeweneeesene +seseneseseseswseswsenwewsesewwewese +wsweseseenwseseesewneeeesesesenwese +wnwnwenweneswnwnenwnwswnwnwnenwwnwsenwnw +nwsenenenenwnwnwwnenwnene +eeenwnesenwseswsesenwesesweseseswe +nwnenwneswnwnwnenwnenenenwnwneswnweswnw +weweeeeeeseesenwneneweeeee +eewsweeenweeeseenweseeswneene +swswwswswnwewnewswseeswswswswwwnesw +wsewwswnewwneewwwwsewwenewww +nwswsesweneenweewweeseeewsewne +nwseswseswswswswswswnweswswsweswswswswnwsw +senwnwwnenwnwwsewwwnenwsenwsenwnwww +swswenwswswsewneswswswwswwnwswenwwsw +nwewwwwsewsenwnwswwwnenesewnwnw +neeesweseeeeneeesewsewwsenenesesw +sewswswswneswneneswneesewswswwnewsenw +wsenwneneneneswnewswseswsweswwwswesw +seswseseswnwenwswseseseseenenwseseesesesw +enwneweeeeeswe +seeswesenewneeseenwsewnwsenesenwsew +wswwnwswwweneswwswswswswnwwenesw +newnwsenenenwenwwwnweneeswnwnwnenenw +nenwnwseswseneswseswseeseeseenwwswese +newenewswwwwwnwwsesw +wsewwwnwwsesewwwwnewnenwsewww +seseseswseseswnenwneseseseseswsewseseswnw +swswsweswnweswwseswswswswenenwwswsww +nwnwnwnwwweswnwwwwnwswenwwnewewnw +nenenwnwsenwnenwnwnwnwwnenwnwnw +seseseswsesenwsenesewseswseswsesesesenw +neeswnwnwswnweeeneneeswneesw +nenwsenenenwswnwnenwnenenwnenwnw +nwwseseseseswsweenesenwseswseeeseese +eneeenewneeeneneneee +neeneneswnewnwnwnwnwnwnwnwnwnwnewnenwse +wewseeseseenweesenwseseeswsesese +wwnwnwwsesewseeewswewnwnwwne +wseswwswnwnwsesenweenwnweeswnewswsw +eewweeswnesesewweneswnesesenwsw +nwnwnwewnwnwwwwnwswnwwnenwse +swnwswneswnwseeswseneswsesesesenw +sweeeseesenweneeeswseseenwwsenenw +nenesenesweswneesewswneeswwwswsww +eenesewnwwswsenewwnwnenwsenenwenw +swnenwswnenenewnenesenenenenenenwnwenenw +seeseseeswneeewseewnwseseseeseee +seewwweweeneeseneeneeeenenew +nwnwnwneswnwenenwswnwwnwnwnwnesweenwnw +swsesweswwswwwneneswswwswswseswnwsw +seswswswswsweneneswwseseseseswswseswwse +nweeseeeseswneeewesesenenw +swwneseseswswswseneswneswseswseseseswswse +seneweswnwweseseseeeneswsesesenwse +wsesenwswsesweweesesenwswnesewsw +eeseeeeeewswenweneesweeee +swnwnwswnwnwenwnwnenenwneenwswnwnwnwnwnwnw +sesesenesesesesesesesesesesenwsenesewwsese +nwnwnwnwnwnwnwnenwnenwnwnesenww +nwnwnenwewwswwseewewwswswswwwsw +senwwseeseswneswswseswsw +nwnweneseseseseseswswswseswseswsesesee +seeswenweeeeeseeseeee +seswseseswseeenwwnenwesesweseswnwsw +seseseseseeseweeeeseesewese +swneneenenenwnenenwnenenenw +wsewnwnwnwwnwwenw +esenweeeeeswenwsee +senenwwenwnwwnwswwwnwnweenwnwnwwsw +eeeeeeenweseeeese +swnwwsewenwsenwewwnwnwnwenwnwwww +neneeewswenenesenenenwnwnenewnwnene +enwwnwwwwsenwneswnwwwnwnwsewnwwwe +sewswswwswseseseseseseseesesenesenwsw +eseseswseesewnesesesesenwesesesese +seeesenwnwnweewswnewseeneeneswne +wwwwwwswseewwwnwsewneswwww +nwswwewnenwswnwenenenwwnweeenenwne +wwneeeseswseswswnwsesenwneswswnesesw +eeeneneneeneeneneeww +nenwwwnwsenwnweswwseewnesenwnwnwne +nenewneswwwewnewseewwsewsesw +neneswneswwsewneesewwnenwneenenese +eswenesewwnenwwsewwswneswnwswwne +eswenwseeenesesewsweenweseeesenee +nwnwnenewnenenwnenwsenenwneneneswenwnw +neenenwswneneswnwnwewnwewnenwneesew +nenenwnweneneswnwnesenwnenwnwnwse +wneseseeswseswswswswesenwnwsesesesenwnw +neneeeeneneneneswneenenenenenw +wwswnwwneeewwesewwwwwsenwnww +nwswswnwseseswswnewswswswswswwswswswe +wnwewnwnwneneeseneeesewswneneewse +wwsewseewwwnewsenwwwwwesenwnw +swwnesenwsenwwnwesenwnenwwnwsewnenwne +eeesewswenwsweeewesewnwneese +newseswswwswwwsewswsewwswswnewnwsw +wnwnwnwwnwenwenweswnwnwswnwnwnwnwnwsw +nwenwnenwsesewwwneewwwwwseswnwse +sesweeneenwnwswenwwseseneeenwswese +weseseesesewsweeenwneneeseeeene +swsewswsweseswswswseeewnwseseswsesw +eneswnesenewnwnenenwnwnweswwswnwswnee +nwswewwseswwsweewseseneesenwnesw +eswseseseenwnwsweeesewewnesenwse +swswwnwswnwweswnewwwswseswwwswww +seenwwneeeeswenwswseeeeenwene +swnewwnewwwswswwwswweww +swseneseswseswneweseswswesenwne +wsewwwwwwnwwwnwnwwwsewnewwe +eeeseneswneenweswnwneeneeenwnee +nwnenwswsenenenwnwnwnwswnwnwnwnwnwnwesw +senwnwwsenenenwnewnwnenwsenwnenenwnwnee +neswswswswwneeswswnewsenenwesewswsee +nwseeeeeseeswwenweeneseseeeee +seseseseswswseswsenwnwewwseseseenesee +esweeeenweese +eneneneweneneeeseeeneenwe +senwnwsesesesewswswswseesesesenenwsesw +senewesweswswnwnwswswswswswswsw +neseseesewswwsenweswnesesesenwenwsww +swnwswswswswswsesesesesenwseswswsw +eseweswneeswwsesesewsenwsesesesenese +neneenweeeeeesweeeeeenwesesw +neeeneeswenwneeswenwe +wnesweneseswwseswswwnesewswnwnewne +eseweseeneneeeeneeseneswswswsese +ewnenwnwneneenenwnwswnwnenwnwnwnesenwnw +enewswneneneneneneenewne +seswnwswwswswsenenewswnwseneswenenenew +enwewwenenweseweeeesweeeswne +eneneneeswnwswneenenwneswnenesweeswee +wnwnesenwwwnwnenwswwnwwnwwseswnwenw +wwnwwwwwwwwswwwsew +enwneneneneneneswneeswseneeenwneene +sesesesesenwseseeseseseswneseswwswswsenee +swneswnwneenesweeneswsweneeneenenwne +nwnwnenwnwswnwnwnwsenwnwnenwsenwwsenenese +neeneseswseeneweweneweeseeneenw +wwswwswnwswneswswwnwseswwwnwswewse +wswwswwswswswwweswsww +swswswnwneseswswsewswswseseneswnwseeswswse +nwwwwnwewwwnwwww +swseenenwewnweswsenwswwseseesesese +sesewneseseseseseenwneweswseenwswsese +nenwnwnenenwswnwnenwnwnenwswneenwseene +neswwswsweneswswwswseswswwnewnesww +swswseseeseesenwsesesenwnwneseeseese +wwnenwnwnwwwwnwsenwwwseweesenw +nwenenwnwsewnwnwnwneewnwwswswww +nenwsenwswnenwnwswnwneneswnwnwenwnenwnw +neneneenenweseewnenene +nwwswsenwseseseeenwnwsesenwenwesese +swswswswswswswswswswneswsewswse +swnwnwnwnesenenewnwnwnwnwnwnee +nwswsenesewwswswswneswswswseseseswwe +swsweswwwneswenwnwewwwwese +ewnewseeseseewseesewseneeenwese +neswenwseeeneswnwwnwwnwseewwswnw +nwsenwsesenwnwnewneswneseneneeenenesw +nenweswnwneswnwwwnwswnwsenenenwnwnwsww +eeeeeweswseseseenwnweeneesee +seseseseswwneswseswsesesese +swwswswswwwnwwwwswwnewwseeswnw +eseseswswseswnwseseswsweswswwseweswse +nwnwnwnwnwwenwwseswnww +neneneneneenwnenenenenwswnene +sesewewnenwwnwsenwswnene +swsenwsweneneenewewneenwwneewne +swnesesesenwseneswnwnenenwnenwswnee +seeswnwnwsenenweneneneneneneneneenew +wneewsesewsesenenwsenewsewwsenenese +nwenwswnwseeswseneseswneseswswseswseswsesw +wsweswneswswswswswswswswswswnweswswsw +seseeeseeeseewse +swnenenwsenwnenwnesewneewneesesenwnwnwne +nwenwsewnwnwenenwnenwnwswnwwwnwnwswe +nwenwswseswwswseseswsweswswswswseswswne +wsweeeneewseweneswnenenwneenenenene +swwswswneseseswseswswswswseswneswswsw +eweswswnenesenwswenwseneneswneswswnene +nwewwnwnwnwenenwswnwsewnwnwswnwnwnw +neeneneneneeswnwneeeeeneweenewne +seseeseeneseseeseseweseswnwsesesese +eeeeewewee +swseneseeenwseewnwseswnenwswnwwnww +seseneswswsesenwswseseswseseswesese +nenenewwswseneeswneswsenenwnesew +nesenenenwnenwnenenwnewenenwnwnewene +eseseseeeweeneseeeseswsese +enwwwwsewwwnenwswsenwnwnwnwnewnwwnw +nwwswwswwnenwwwwwwnwneseewsee +neneswnenenenenwnenenenesenewenenenene +wwwneweswwwswwwwwneswswwsww +neneneneneeenenwneneswnenenenene +seseseseswseseseseseneseseeneswenwswsese +eeeswneswseeseswswseeneeneeenwe +nenenwnwnesesenwnenenwnwnwenwswnwwwnwne +nwseseseeeseseseeeswnwsese +eseseeseenwwseweseseesewseseseee +enwneswwsenenenenenenenwwnenesenenenenene +nweweswnwwnewwnwnwwnwwnwwswwe +wneswswneswswswsewwwswwnwsewswww +nwenwswnwnweswseswsweswswswswsw +seseseewsenwswnweswsenwew +swwwenwnwnwwwwwwnewwnwnwsewwew +swnwwsweswsenwsenewenewneseeenese +nesenwnwnwnwnenwnwnwnwnwnwsese +nenwneenenenenenenenewnenwseswswnenene +enweneesesweeeeswenwenwenweeesw +wswnwnewwwwswwwnwwseesesww +nwwwnenwnwsewewswnweswww +swswswswnenweswswswswswswneswswswneswsw +nwsewswswswswswswnwweswswswswswswswnesw +senwnwnwsenwwwwnwnwnenwnwnw +senenewenwsesenesewswsewneseseswswnewne +wnwwnwenwwwwnwwnwwwnwnw +nweseenwseseseneseesesesenwsesesewsw +seseeeseseswnwsesese +wwwwnwnwewwwwwswsewwnewww +neneeeeeeeeweeene +eneneneneneswsenenenweneseeenenwnewne +wesenewseswswswseewswnesewseneswsw +eseeseesesewseswsesesesewnwsesesee +nweenwseseeseneeenewsesewswwse +nwnesenwnenwwnwneenwnwnenenenwnwswnwne +seseseseseswnenwsesesesesesesesesesenesw +neneneneneenenewneneneneneneneswnwwe +nwwswnwnenwnwnwsew +swwnewwwnwneenwwwwnwsewswwww +swswwnwswswwswwswswswse +nenenwnwnwneeneneenewnenwnwsenwnwswsw +swswswneewsenewswnw +newneeeneseeenenwneeeeewneee +seswseswnwsewseseswsesesenwswseneseesesesw +nenwwnweeswnenwsenenenwwesesenww +nwswseswneswswswswswnwswse +weseeeseseweeseeseseenenwseseee +nwwwwswewswwswsewnwnwnenewewse +wwswnewwwwwwwwwwww +wnwwnwewswswesenwewnwwwnwnwwwne +nenwnwnwnewwnwnwwswnwnwenwnwnwnwsenw +nenwnwneswseswswneeneeswnwnwswnwseswnenw +senwwseneneeseseesenwwseeswseeeseene +senwneenwseenwnwwwneneneenwnwnwnwsew +sesweseseswnwswswnwswseseseseeswseseww +nwwwnwwenwnwnwnwnwnwnwsewsenwwswew +swneswwsewsewseeswswnenwswwwneswnenw +enweswneeseswsesweenwneswnwneenwewe +ewwswnwwwwwwwnwwenwnwnwwnw +nenenwnenwnwnwnwnwnwse +swnwsweneswneeesenwswewnwneseeesw +eewnwnwseswenwswsewnesesesenwnese +nwnenesenesenwwnenwnwnwnwenwnwwnwswnwnw +nwseswnwesenwnesee +newseswsenwnwsewswneneenewnwwnwne +eneneeewenenenwneeeenesw +wswswswwneswswwswwsw +wswseseswwnwnweenw +wwwwwseswwwenesw +neenenwenenenwnesenwneenenenwwswnesw +swswneswenwswswswwswsesweeswswswsenw +sesenenwsenwnenwneswnwnwwswnwnewnewnw +nwewwnwnwwwnwswnwenwenwswewnww +neeneneneeswneneneneswnenwnenenw +nesewewewsesenenenweenenesweswsenw +wnwwseswnwwswnweneswewnwnwnwwnwe +eeswnweeeeseeseeewneeeenweee +wswwswsenewsesewewnewsenwnwwwnw +wswesenwnwneswnwe +wwwwwnewwwwswnewwsenwnwnw +swswsesesesesesenwesesenwse +nwnwnwnwswnenwwsenwnwnwwwnenwnwsewnwnw +neswswswseswneswseseswnwwswswnwneswswswse +wswwwnwnwwnwwsewnenwwwneswwwne +seesweeeenesenweeeweeeenwse +senwnwnwnwsenwneneswenenwwnenenenenwnenw +swneneswwneeswwswwsenwwswnwneswsesw +neeswswsweeeneesweeeneeeneeswnw +nwnwseesenwwnwnwsesenwneenwnwnwwnwne +sewsenwwsesewwseeseeswseeeseesese +swneswswswswswnweswswneswswswswsww +swneswswswseseswswswwswneseseswswswsenesw +eswnwwwswneesewwswwwnwwwwswse +nwnenwnwnwnwnwswsenwnwnwswnenwnwnwnwenw +eenenwswnwneswsenwswnwnenwswwnenenwsw +senwswseseseeeeenw +neneneneneswnwnwwnenwnesenweneswnwnese +swnwwwswswswwwwseww +swsesenwswswnweseseneswswswsesesewswsw +nweeeeeneeeseene +esesewswsesesewnwsewseewnenwnesene +neenwseeweeweswswnwese +wnenwnweseneeesenewseeswww +nwnwnwnwnwnwnwwnenwnwnwwnwse +nwnwseswnwnwwwnwnwnwnenwsenwnwwnenenwnw +neewswnenwseseswwnwseseeeseesenweese +seswswseswseseswewswwswneseswswseeswnw +eeeeeesenwswswenenwneeeewsweswnw