2020 Day 24 Complete

I made some minor changes to helpers/coordinate... I probably need to go
back and fix several previous years/days.
This commit is contained in:
Brian Buller 2020-12-24 09:58:15 -06:00
parent 3b5bae7948
commit 10a3ba0699
5 changed files with 701 additions and 4 deletions

539
2020/day24/input Normal file
View File

@ -0,0 +1,539 @@
swswswswseswswseseswswnwsesw
nwewsewneswenwesenesenw
neeeenwseseewwnenenesweeeeene
seseewnwseseseneswseeseseseesesesese
swseswswswswswswswswweneswswsw
seswsesesenwsesenesenwseseseseseseseesew
nwneenwneswnwneneneseneswnwnewnwsenene
wswswwwswswsewneswnwnwsenwswswewesw
eeseeneeneeeneew
swnewnwneneeneneseneneneneneneenenenene
seewswnwseneswnenenwww
eneneswnenenwnwwneneneseneneneswneswne
nwewswesewseseeewneseseseseeese
enwsenesweswwsesewsesesesesewnewsene
wseeseseseseseseseseswsesenesesesesesese
nenewnenenesenwsenewneneneswneesw
eseeneseneesesesesweseseeseewsewe
nenenenenenewneneneneneseeneswnenenenenee
nwsenwnwnwnwnweneeswnwenenwwnwnwwnw
neewnewneeeneneseeneseneeneneneeww
neswswswneswseswwwnwwwwswseswsewnene
wnwnwenwwewswwnwnwwneswwsenwese
wnwsewewwwnenwwwwnwnwnwswnwnwnwnw
wewwwwwwswwnwsewwnwnw
wsenenewsewwnese
wnenenwswseesweene
nwnwnwnenenwnwnwnwnwnwnwnweswnwswnenwnwnenw
swseeewnenweenwenenwswsenesw
wswswswswnwsewswneswswseswneswneswsesww
seswneseswswswseswwwseswswneseswswswnesw
sesweseswnwswsweseswswwnenwnesenwsew
newwseneseeseeseseseseseesesesewse
swswewwswsweswswswwwwswwnwswsewnesw
seneeeeeseeseeseseeeesesesw
swsesenwnwseswwseswswseseseseseswseseswne
wswwwneesewnesenwwswwnwwswnw
eneeeneeeeeneneneneneneeesewwnene
swswswsweswnwswswswswswswswswswneswswsw
sweswwswswwswswswswswswswswswneneswwsw
wswwswswenenwewnesweesenesesenenwe
sweneneswnwnweswneneeneeneswneeee
swwsweswswnwswswswswsw
nenewnwsenenenenenenenesewnenenenenene
nwenenenenwnwneneenenwnwswswnenewnenw
seswwsweswseneswswnwswwnenenenwswsewswse
seneswsenwnwnwnenwnwnew
esweseneeewseweeseenesenwnwswe
wswswsenewenwswwwwwnewswswesewwsw
seesewenweeeweseswwseseeneese
wwwswwnewswwewwsenwneswwwwsesw
wseseseseneneseswswseseseseswe
enenenenenewswneneneeneneneenweew
ewseneseenwneseneswsewnww
ewwwwswwwswwswwwwswwswwwnw
neewseswesesesewsewwnwseseseeswe
swwswwswswwwswswswwswswnwwswswsewe
wneesenesweenwsenwsweneeeeseew
wseneseenenwwwneesweewnenenenese
seenwwneneenesenewswnenesewnesenesew
nwnenwsenwnwenenwnenww
nwnwneeswnwnwewnwwswswnwnewnwsenwnenw
swswwwwneswswsweswswneswswsewswswwsw
eneneeeeewneee
seswswswesweswwswswswswsenwsw
wswswseswwwnesweswsweswswwswwwsww
eeesweeneeewnwneeseeesweneeee
nenenenenenenwneswnenenenwnenenenenesenene
nwwnwwwwwwwwwwew
eseseseswswsewswsesenwswswseswsweseswse
nwwswnenenenwneneneneenesenenenenenesene
seseseseswneseswswnwseneseneweeneswse
nenewnwnwnwwnwwnwwwnwsenwnwsenwnwnw
wwwswnwnwwnwnwewnw
neswsenesewsesesesesesesesesesewsesese
esesesweseeseeeseseeeenwesewese
wnewewnwwnwswnenwswwswwnw
wnenesenwnenenenwsenenwswnesenenenenene
eneseeeeneeneenwneneneeweswenee
seswnwwswneswseswseswseseswswswesesesw
nwswseseeswswewswswsesenwwswwswesesw
wewsenwnwwnwnwnwnwwenwwwwnwew
enwwnwnwnwnwnwnwnwnwwnwswnwnwnwnenwsenw
nwsewewwnwnwswnwnwswwnwsenwnwneee
wwewwswsesenwwwswewwneeeneww
wnewsewsenwwwnwwwnwnwwwwwwnewsw
wnewnwnweewnwsenwnwnewswswnenwswenwnw
wnwwswswwwnwwwwwnewnweww
wwswseswwwswwswnwwwnenewwenww
wswwswwenwwswwswwswswwswswswesw
ewswwwwenwwsenewnwwww
sewnwneswseswseswwswsewswneswnwswseswnee
neenwswewsenwwswnwswswwswneewswwe
wwwnwwwwnewewwwnwwwswwww
esesenwseseeeswseeeseenweseesesese
esesesewseseseneseeseeswseesesesesese
seseseseseseseneseswseseseswsesesesewse
sesesewseeseseneeseseseeeewnesesese
swswswswswswswnwswswswwnwswweeswswsw
seseseswwseseseseseseseenesewseeenew
neeswnwswneewnenenenenenenwneswne
nenwnwenwnwnwnwnwnwnwnwnwnwnwswnwnwnwnw
sweeeeseeeeenweeeseenweseeee
nenwseneneeenenesweneesenenenwneenene
wwneswswwwwwswwswnewwseswwwwsw
swsenenwseswnwseseseneswnesesesesenewsenww
nweswwseseseseswnwnwsesesesenesesesesesw
eneseseswwsweseswswsesewseeswswswnw
nwnwnwwnwwnewwnenwnwsewnwseesewnw
seseeeeeesewnweeeeesweesese
eeeswneneneneswnenenenenenenwneeene
nwseseseseseseseseseeseseswseseseseesenw
swewwwnwswsweeswnwwwnwwwseww
nenenewewseswneneeneneswneenenene
sewnewwwwwwwwnwwwwnwwwsweww
nesenewneneneneneneneneswenwweeenesw
swswwwneswnesewseswswwswswnwwswsww
nenwnwnenwsenwnwnenwnwnwnwnwwnwnwneewswne
eenweeeeswseeenwseeseseseeesee
seewenenenenwswseneeneenwwneewnee
seseseeeeeseneseseseesesesewseese
wwwenwseswswswswswswewswswswwnew
swwwsewnwesewswneewwesenwnwwne
neseesenwneswenweeesew
nenwesewwneswseseeswseeseeeseese
wwwnwnwwswnewwnwww
eseseseeenwseeeeeeseeeseenewee
nwsenenewnwnwnwnenwnene
swswswswswseswswwweswseswseneseswswsw
nwnenwnenesenwnwnwsenenenwsenwwenwww
neswwwwwwswswnewswswsww
nenwsenenewwnwnwnenwnenwseseenwnenewne
wnwwwwsewnwnwnwnwewwwswnenwww
nwnwwnwnwnwsesenwnwnwnese
wwwnwwwewwwnwweswnwwswnwwnwnwnw
nwnenwnwnwneenwneswnwnwnenwneeswnenenwnw
sesewswswswneneswnwwsewswswnwswwnee
nwneneneneenenesweneeneneneeswnenee
neeswenenwweesenwseneswee
nenenwneswnenwnenenesw
nwwwnwswsewwnwwewewsenwnwnwwnw
nwnenwenenenenenwwnenenwnenwnwswneenene
wwnwwwwwwnwnwwwwwwewwwwe
eeneeeeeeeeweseeesweswnwnene
enenenenenenenenenwwnewnenenenenenwe
esweeswsenenenwswswswwwseswneswswsww
eeeesweneeneeweeeneeee
nwseseswswswwwnwenewnenwsw
sweeeswnwseneeeeeesweeneseweee
swswswswneweswswswswswsw
swwsewnwsweneswweswnwswwseswswswww
nwnenenenenenenenwnwnwsenenenwnesewnwnenw
swseeeseweseseseseseesesesenwsewnee
neneneswnenenwnenenenwnwsenewenwswseswsw
sweseseswnwswenwsesweseeeseesenenese
seewenwsesenweeeseeneseeseseeswee
eneeeseseeeeeseeswweeseeeswenw
wwswswswneswswswwwswwswswswswsw
eeneenenwneeeneneeeeneeswenene
swwswwwnwswwseewswswwswswwswswswwnw
nenenwnenenewnwnenwnenwnesenenenene
neeswnweswneneewneeneeeeeee
swneneswseswswseswswwswswswswswnwneswsw
enwenwnweeseeweswswnwsweeenweswe
newswnenesewwwsweswwswswwswswswsww
nwwwwwnewwwwwsewwwwwwewse
eneeenenenwneneeeneseswnenenenenene
wswwneswnwwsewswseww
nwnwnwnwsenwsenwnwenwwnwwnwewnwnwwnw
wseneneenewnweenewwnenenenwsenwne
eswneneneneenenenenwnenwnenwnenwnwwnenene
swseneseseswsweswseswsewseseseseseswsese
swswswwswwwswswswsewswwswswswsweswnw
swneewenenwneewnweseswnwwnw
wswwwwwewwwwwwwww
nenenenenenenenwswnenewswnwneneneneese
sewsesewsesesenwseneneseseeesesewe
swswswswewswswswswswswswnwswswswwwsw
wnwsenenesewnenenesewnwnenenenenenenenene
newwwsewsenwnwnwwwnwnw
neswswwswneswswswneswswseswswswwswww
nwsewwwswweswswwwwswnewswswwwwsw
seseseswseseswneswswseseseseswsesesesenw
senwwwseswswseseswwswnesewnwnenene
eneeeeeswneneeneesweeneenenene
eeeeeeeeeneeweeeeesee
nesenwneneenenenwnenwswnenenenenwnwnene
neenwnenenwwnwswnwnenwwswenwnwnwswnw
neeneneeneeneeeneeneneenwewenesw
nwseswswnweenewwnenwnwnwswneeswwnw
swnewwwnwnwseewweswwnwwsww
nwsesweweewwnwwwsenewnewwwnwwsw
seeswsenwnwwswseswswsenwesweenwsese
nwwseeeeeeeeeeeeeeeeeene
swneswswswseswswwseswneswswswseseswswsww
esesesesesesenwseseswsesenesewwsesesw
eneeneneneneeneewneeneneneneene
wwnwnwnwwnwnwsewnwnwenwwnwww
seeseseesesesesesesesenwnwseseswse
nwwnwewseswnwwswwnwnwwnwsenenwsese
nwneswnwnenwnwnwnwwnwnwwnwnwnwnwnwseenw
wsenwnewswwwneseweswnwwwsenenwnew
swesesewsewswswsweswswswenwswseswswsw
eweeseneeeeseeeseeeeee
swwwsweweewneswswnwsenwswswwswswsw
sweswnewnwneenwswweseeeneseseseew
nenenesenenenwneneseneneswnenenwnenenenwnw
swswswsweswwswswswswswseswswswnwswswnwsw
eeweeeseneeneeneeeneswwsee
ewwwwwnenwwwwwwwsewwwwnww
nenwswnenenenenenenenwnwnenweseneswnewnw
wswwnwwswwswnwwwwwwwswesesw
sweeneneswsewneeeneneneneneenenene
enenwnwsenwwnwswnwnenenweswne
eenwswwnwenwenwesweswnweswswsesww
swwseseswnwsesweseswseseswswswnwnesesese
seeeeeeeeeeswnee
newsesesenesesweswsesesesesewne
enwnenwnwnwwnwwswwnwsenenwnwnwnwnwsw
nwswseneeseswwnwswnwsweenwneswnene
neswswswseswswswwewsww
seseseseseseswseseseseseswnenwseseseesesese
seswseeneswnwswsewswseswseneswswswseswnw
neneesweeneenenwneseesweneeneneenw
swsenwswsenwseneesw
wnwwwswwswwwswswswswsewwneswswsw
wswwwswwwnwwwwwnesewswwwwe
swseswseneswsenesesewswseswseswwsenwe
newnweneneneneneneneseeneneneneneewe
eseseseseneeseswsenwsesesesesewenwew
wseeenwseseneseewswseenwseseseseese
wswwnewewseswwswwswnewwwneswsww
wsenenenwesenewewnwewseeeseswswsese
nenenenenesenenenesenenenenenwenwnenenene
eweseneneeewewne
seseswsenwesesesenwweeeseseeeesese
swenwwneseseweseneweswswseseswnwswswse
seeewnwnenwwswnwnwnwenewnwwswsene
seneswswneseeswnesesesenesesewnewseesese
swnenwnweneeswnwnwnwnw
nenenenwneenesenene
swsweswsenwseseswnwseneseseseswseseseswse
swneswswswswwswwswswnwewswsweswnwsw
nwenenewnwnwseeeseseswewnenenwswswnew
eeneseweseseseseewee
nwseseseswswwseswneseseseseseswse
nwwswswswwswwwwswnwswewwsewswe
eeeseewseeeeeeeeeeneeee
eweeeeseneeneneeneeneneeewew
nwsenwnenenenwnwnenenenwnwnwnwnenenewne
swswswswseswswseswswswswswswswswswnwnwswsw
swswswseswseseswseswswseswsenwnwswsesesesw
swnenenenenwneneneneneneneswneneneneneenene
neneneeeenenesenewneeneeneenenee
eesesesesesesesenwwnwseeesenwswswse
senwswnenwseneeswwseswe
eeeweeewseneneneeeeneeneee
eeeeneeenesweewenew
nwswwwenwsenwsenenwswwweswsewwnwne
swswswseswneseseneswnwseseswsesesweswswswsw
eneenwneneeeneseneneneeeesenwnee
swwnwwnwsenwswwswseenesewseenewwe
eeseseweeeewsenesesesewee
nwsenwnwnwnwnwnwnwwwwnwwwnwnwnwwenw
neneswneenenenesenenenenenenwnenwnwnesew
eseseeeseswswweesweeeneesenwne
swswswseswwswsenwneneseseseeswseswnwsw
nwnwnwnwwnwwnwnwwswnwnwnwnwnwnwenwnwe
wnenwnwnesenwnwswneneenenwwneenwnwnene
seewseseseseeeenweeeeneseseswsee
swsenwsenwnwseseseswesweseswnw
swseswswswsweswswseswswswswseswsenewswsw
seswseseseswwesesesesesesesesesenwswnese
wswnewwseswswwswwwswswneswswwseswsw
nwwsesweeseseeseenesesenweeeesesese
neseeeseewseeseseesewseeese
nwnwnenwnenenenwnenwnenenenwswnwsenenenw
eseeseeseeswseneseseseeeseew
swswswswsesweswsesesenwswseswsesesesesw
wnenwneseseesenwwnenwswswneneweee
newnenenenwnwenwenwswneneseneneswnene
nwwnenwneneneswnwneenenwnenenwnese
eweewwwwwnewwwewwwwnwwswse
ewsweenenwnwswswnwnwnwswwnwnw
esenwnwnenwnwwnwnwwwwewseswwwnwsene
wseeeeeeseseseenwseeeseeseswee
sesesesesenwnwsewswseswseeeseseswnewne
neneneeneswnenenenenewnenwnenenesenenene
wseneseweneeeeew
sesewseseeseswsenewsesewsesenesese
neeneneswseneesweeseeneneneenwnwe
swswseswswswswwneswswswswswswswswswsw
wwwwsewswwswswwswneswwwwswww
seseseseswneseseseseseeseseswsesewsesesew
nwnwnwswnwnwnwnwnesenwnwnwsweenwnwnwswnwnw
seesewnwswneweeenweeseeeseseneswe
seesesesesesewseneewesesesesesesese
nwneeeewewneneeenenesenwswswswe
seseewneneeneneneneneneswwnwneewse
sesweeswwnweseeeenweeeenwee
wwswwswwwnewsewwwnewswweww
swswswnwswnenweseseswswswnenwswswseswswsw
eseswneeeeeneseeenenweeswesesesw
seseseseswswseswseswswswsenwswesesesesw
sweeenenenenwswnwsweeneneswnweeesee
wnenwnwnenwnwwswnenwnwseee
newweneeeeeseneeneswneweneenee
wswswsweseeswneseswswswenewnewwse
swswswweeneswenwswnw
swswsenwswseswswsesenwsesesesesesesesee
nwnwsenwnwnwnwnwwnwnwnwnwnenwnwsenwnw
seswenwnenwsewnwwnenwsewwnwnwesene
enwseweenweseseseeswswseneswesene
newnesenewneneseneneneneswnewneneneenee
swwwswwnwewneswwwwswswwseswww
sesenwweneneeswesenwwewnenw
seneseeseswseseneseswsesesesesesesesee
neneeeeneseneweneneneseseewewwe
eseeseseseseseeswswseseneseneseesee
eseneswnewswneswwsenenenwnwsenwwsww
nwnwsenenenwnwnwnwnenwnwnwswnenwnwnenenenw
nenwenwnwnwswnenenenwnenenwwnenwesenenenw
swswswseswswswswswswneneseswswswseswwnwnw
eeeewneeeeeneeneswnwesesw
eneneneeesenenesenwnwneeeeseeenew
seswseswsweswswswswseswswnwseswswse
nenwswwswswswswwswnewswwswswwwswwe
nwwnwswseewwwwnwwnewswweenwnwnw
wsenwnwswnwnwwnwsenwenwwnwnwnwnwwwnenw
swsweswswseswswswnwswswswswswnwseeswneswsw
swneswswwswwswswneswswwseswseswswneswswsw
wwwnwwwnwwseewewwnwwswweswne
wwnwnewsenwnwwwwwnwnwnwnwnwnwnwnw
swnwnwnwneneneneeneenwswnwnenwnenenese
nenwsenenenenenewnenwnenenenenene
swswswwwwswswene
neneeneeneneswneswnwnesewneenwnwnenesw
wswwwwswwswneswswwseeswswwwww
nenenwswsenwnwsesenwnenenenwnwnwsene
nwenwseeeenesweswseweseseseenwnesee
esenwsesesewseseneseseseseswseseseswsese
eeeweenwnewseeeeseswsenenwesesese
weeeeneewseeneeeeesweeswne
seseswsenesesesesesewsesesesesesesesese
neneenwneweseseeeeweeeeeneeee
eeesweeenwneeswnenweeeeeeenee
ewwnwwnewweswnwwsewewwnweww
eseneeeweeeeeeeeenesweenene
swswswswswwwwwswwneswneswswswswswww
sweeeeeneeeeeeeeeeneswsee
swseswseswneswswswseswswswswswswswswwsw
swnwsenwnenwnwwnwnwnwnwwsenenwenenwnenenw
nwseseswseseseeswnwswseswseswseswsenwse
swswenwnwswwseswnwsewseeneswseneswswnw
newseseesewnwsweneseeseseewseseew
wwwwnwwwwwwwwwewewwwww
nwswnenwwnwwnwnweesewnwnenwnenwnwnwnw
swneeseewsesewseewseseneneseseeeee
senweswnwswesesweswsewseeswswnwse
neeneeeeeeneswneneeweeseeneee
nwwnwwnwwswwwnesenwnwwwwwnwwnwse
nenwnewnwnenenwsenenenwnwnwnwewnwnwne
wnenwnwwnwwwewswswnwwwwnwnwwwww
neneseneneswnenenwwneneneeeneeneeenew
swswwswswswneseswswswswswnwswnwesweswsw
eweweeeeeeneseeewee
nwwswwwsenwnewswwseswnewswnweww
swswsesewsweseneeswswswsweswnwnwnwswwsw
swseswswswswseseseseswswseseswnwnesesesw
nwsenesweswnwnwsesweeswewsesesenesese
nwseseswseseneswsesenwseseseswsesesesenwe
seseeseseseseseseeseseesew
nenwnenenewnenenwnenwneneeneswenenwnenw
wnewwswswseswnenweswswswswswnwswswswswe
neenwswwnenenenwnwswenwenwnene
nwnwnwenwnwnwnwnwnenwswnwnwswnwnwnwnwne
seewwsenwwwwweswswwnwwwwswww
nwnwwwnwnwsesenwneenwsenenwswwnwsenwne
nwnewnwenwwneswwnewwswswwnwwnwswnwnw
seeeeeeeswseseseseeseeenwsesee
wnesenwwwwwnewwwsewwswwwwww
nwnwnenwnenwnwnwnwnwnwwnwnwnesenwnwne
nenewnwnenwswsenwenwnwnwnwneewnenwne
neeenwneneeneswweeeeneeeneeeee
nwswenenwnwnwswnenenwnwnwnwnenwnenwnwne
neeswswswswswswswwswnwswwswswswswesw
nwnwnwnwnwnwswnwenwnwswnwnenwnwnwnwnwnwnwnw
newwnwwsewwwwsewwewwwswsenwsw
nwseswneswwswswwswwwswswwwwseswwsw
wwswswwwwwwsewswwnewwwwww
seseseesesesesewsesewsene
wswswswewswswwewwwswswnwwswnwww
swswseswswswnwswswswswwswswswswswswsw
nwsesesweewnwneswwnenwnwnwsenenwswsenw
swswseseseswswseseseseseswswsesesene
nwesewwnwneseeseneswsesesweneseenwswsw
eeseeesenwnweesweeeseeeesesw
neeswwnenwnenenenwneenenenenwneswsesw
nwwwesenwwnwnwwwnwwnw
nwwswwwwenwwnesesesewenewswsww
swswwwwswsewwswneswswswwwsewneswswsw
eneeneneswnwnenewseeneseneesenenewene
nwwswwnwnwwnwnwnwewwnewnwnwnwwnwe
nwsweswnewwwwsweswswwesw
nwneenenenenenenewswsewenenewsenenene
seswseeseseseneewsesweseseneseesesese
swswswsweeneeewewnewwnwswnewsw
wneswswwsewswneseswswswswwsw
eneneeneeeneseneneswneenwneneenene
enwnenwswsweneeswenwwseeee
nwnwnwnwnenenwenwnwswnenwnwnwsenwnwnwnenwnw
sesewsenwseseesewnwsenesesesesesesese
nesenwneneswenenenenewnesesenwewsenew
seseswnewswesenwneswwewwneeseeswse
wseeseenweeeeeeeewswneeee
nwsesesweswsewseseswsesesesewswseneese
nwnwwwwswwwnesewneewsw
nwwnwsenenwneneneswnenenwnwnwswnwnw
swnwnesewwwnwwwwnwwneenwswwwwww
seseseswwneswswsenewneswswwswseswswse
eseseweenenewseneseseseseswseesew
seswswswnwseseswswseseswswswswsenwsenwnwe
swswswwweswwswswwswswwwswswswsw
wnwwnwwwnwwseenwesenwwnwswnwnenw
nwnwnwnwenwnwnenwnwnwwnenwneenwnenwswnenw
nwwsesesenwweesese
nwswnwnwnenewsewse
eswswneswwwwwwwwwnewwwwswnew
wwwswsewwwwwnww
swswswwwwwewnwwsewswwnwewswnee
nenwewneswnenwswnwswewneneneseswenwene
wnewwwewswsewwwwswnwwwwwwwsw
seeseseesenwewseseseseseseseesesee
wwnwwwnwwwwsewnwwwswwnwnwwe
ewsenenenwswswswswnweseewnwswsesenwsw
wwewwwwwsewswwwnwswwnwwwww
neswsweneseneswwwenesewswswewwsw
neneenenwnwnwswneswneswneneneneswneene
seswnwsesweswsewswnwnwneswnwswnwseswnesw
neswnwnwnenwnwnenenenesenwneneenenenwswne
esenwsesweseneswesewswenweswnesewne
enwnwnwnwnwnwswnwnwnwnwnwswnwneneenene
eneeneswnwneeweneseeesweneneenene
seseweeneswnwseseenwseseseseseeese
eswenwneeenwneseeneeneee
seseswseseseseneeseseswwswwswseseesese
nwseswswswswseseseseneswseseseseseseswswse
nenwswnwswnwnwnwnenwnwnwnenwenwnwnwnwsene
seswwesesweswswswsenwnewwsweswsww
eeeeseseeseeeeesenweesweese
eesenwesweeeeneenweeseeeeee
esesesesweseeesesenesewseseeesee
neneeeneenewnenenenenenesewse
nenwsenwnwwnwenwnenwnwswnwenwnwnwnwnw
wwseneneswnenwneswnwsesenwweseenewnw
swwswnwswwsewswswswswwswsewswswnesw
seeeeneesweweeneeeeneneneeenee
swswswnwseswswswswswnwswswswneswseswesw
wnenwwnesewwswwwsewwwnw
nwsenenwnwwnesweseswnesenwnwnenewsew
ewnwswswwwswwswwnwswesweewww
seeseswsesenwsesenwnweswswswswsewswsene
nwnwnwswnenwnenwnwnenenwnesenwesenwwnew
nwnwwnwnwnwnwwenwsenwnwwwnwnwwnwnwnw
wwwnwwwwseewwwwewewnewww
neswwwswwwswswsenewswswwwwwswwsw
swsewseeseeswseswwswswsesw
swswwswesewswnwswswswwsww
swseswswseswswsweseseseseswnwseswswswsw
wsesesesesesesesesesesesesesee
wnwwswseseneneneenesenenenenenenwee
ewsweswsenwseswwwnweenwnewnwnesew
nwsewneswwwwswneeswwsw
nwnwnwnwnenwnwenwnwneeswnwnwnwnwswnwnwnwnw
ewneneswesenesenwnwnewseww
nwnenwnwnwnenwnwsenwnwnwnenenw
eeeeeeenweseenweeeenwseseesw
wswwswewswwswwswwsw
nweesewseweseenwseseee
nwnenwnwnenenenwnwswnenwsenwnenwnwnwwnenw
nwnenwnwnwnwsenwnwnwsewnwnwnwnwnwnwnwnw
nenwnwnwnwswnenwnwnwnwenwnwnwnwnwnenenw
sweeeeeneneweeeeeeneeeenw
neswsewnenwneswnenenenenwnwenenwnwnenwne
nwwnwswnwswnwnwnwnwnwnwnwnwnenwnwnwnenw
wsweenwenwewneeweeswswwewee
sweswnwwswswswnweswswneswseswswswsesw
swneswswwwswwswewewwswwwwwnese
nwswswswswswswswswswseswswnewswswswsw
nenwnewweewnwnwswnwwsewwwswsenw
seseeewewseseseseseseesesesesesesese
swseswseswswseseswnwseneseeswnweswsesw
wenwnwnwnwnwnwsenwnwnwwwwnwwnwnwswne
nenenenenwnenwnewnenwswnwneneneneneenenw
nwnenenenesenwsenewnewnenwnesenenwnenenw
neneneneeneesweeeneneneneeswenwne
neneenwneeneneeswneeeeenenenenene
swseswseswneswswseseswsesesewnesewneseswsw
swneseewneseswnwneenwswseseseeswese
nwswnwnwnwwnwnwnwnwnwwnwnwewnwnwnwse
nwswnwwnwwnwwwewwnwwwewseenwnw
eeewneneneneeeswseneeweneenew
nwswswswswswswswswswswswwswneseeneswswsw
nwwwnwnwwnwswswnwneewwnwnwnwnwnwnwnw
swswseseeswseswseswswsesew
seesesesesesesesesewseswseseseseene
eesweseeneseswnweseweenwseesesee
enwenwswnenwnwnenwwnenenenewnwswesenwnw
enwweeseenweseeeeswesweeeneee
nwnwseswnewenwnewwsesenwnewnwnwnenwnw
swswswseswweswswswswseeseswneseswsenwne
nenwnwnenwnwnenenesenewneenenenwnewne
swnwwnwswewnwwnenwsewewwwnwnwwww
swneswswwwswnesww
eeeswwnweseweseneeeswsesesesesee
swswwseeseswswswswswsenesenwswswsesenesw
swnewwesenwneswenwenwe
wnwnewwwsewwwwswseswwwswwwsww
swwnwenwnwwnwnwsewwnenwnwwnwwww
nwnwnwnwnenenewnwnenwnwsenenwnwnwnenwne
nwnwnwnwswnwnwnwnwswnwwwenwnwnwsenenwnw
neneneswneseswneeneswnwnenewenwenwswnwne
sweeneseseeseseeneswnweeseseseeee
enesesewwenwwwnewneswsewsewnwnw
swseseseseseseeseseseenwenwswswenwnw
swseseseeneseseswswseseseseswsewsesesese
nweseneswseesenwseswseseswse
swewswseseswwwseneswnesesene
sesesesweseseeneeseeseseseswenwsese
nenwwnenwnwwswwswswwnwnewnwwwnwnww
swswswswwsweswswewswswwswswnwswsww
swwnwswseswsweseswswnwnenwnwsweswee
nesewnwnwnwenwnwwnwwswnwnwnwnwnwnwnwnw
newnenenenenwnenenenenenenwnenenesenene
wwswewwwwswswwwswwnwwwewsw
seeeseeseeeseeseeseeesenwsesesw
neneswseeneneenenwnwnenwnenesenenenewne
nwwneneseswnenenesw
nwnwnwswnwnwnwnenenenwnwnwnwnwnwnwsenwsw
swnwwwnwewwwnwnwwnewwwwnwwnw

124
2020/day24/main.go Normal file
View File

@ -0,0 +1,124 @@
package main
import (
"fmt"
h "git.bullercodeworks.com/brian/adventofcode/helpers"
)
const (
White = iota
Black
)
var tiles map[h.Coordinate]bool
func init() {
tiles = make(map[h.Coordinate]bool)
}
func main() {
fmt.Println("# Day 22")
inp := h.StdinToStringSlice()
solve(inp, h.Atoi(h.OptArgNumber(1, "2")))
}
func solve(inp []string, part int) {
buildTiles(inp)
if part == 1 {
fmt.Println("## Part 1\nAnswer:", len(tiles))
} else {
for day := 1; day <= 100; day++ {
next := make(map[h.Coordinate]bool)
lx, ly, hx, hy := getBordering()
for y := ly; y <= hy; y++ {
for x := lx; x <= hx; x++ {
tst := h.Coordinate{X: x, Y: y}
_, ok := tiles[tst]
bl := CountTiles(GetAllNeighborCoords(tst))
if (ok && !(bl == 0 || bl > 2)) || (!ok && bl == 2) {
next[tst] = true
}
}
}
tiles = next
fmt.Printf("Day %d: %d\n", day, len(next))
}
}
}
func getBordering() (int, int, int, int) {
lx, ly, hx, hy := h.MAX_INT, h.MAX_INT, h.MIN_INT, h.MIN_INT
for k := range tiles {
lx = h.Min(lx, k.X)
ly = h.Min(ly, k.Y)
hx = h.Max(hx, k.X)
hy = h.Max(hy, k.Y)
}
return lx - 1, ly - 1, hx + 1, hy + 1
}
/*
o o
o o o
o o
*/
func buildTiles(inp []string) {
for k := range inp {
curr := h.Coordinate{}
var last rune
for _, r := range inp[k] {
if r == 'n' || r == 's' {
last = r
continue
}
curr = GetNeighborCoord(curr, last+r)
last = 0
}
if v := tiles[curr]; v {
delete(tiles, curr)
} else {
tiles[curr] = true
}
}
}
func CountTiles(c []h.Coordinate) int {
var ret int
for _, v := range c {
if _, ok := tiles[v]; ok {
ret++
}
}
return ret
}
func GetAllNeighborCoords(c h.Coordinate) []h.Coordinate {
var ret []h.Coordinate
for _, v := range []rune{
'e', 'n' + 'e', 's' + 'e', 'w', 'n' + 'w', 's' + 'w',
} {
ret = append(ret, GetNeighborCoord(c, v))
}
return ret
}
// Translate hex neighbors into a 2d plane
func GetNeighborCoord(c h.Coordinate, dir rune) h.Coordinate {
switch dir {
case 'e':
return c.East()
case 'n' + 'e':
return c.North()
case 's' + 'e':
return c.South().East()
case 'w':
return c.West()
case 'n' + 'w':
return c.North().West()
case 's' + 'w':
return c.South()
}
return c
}

20
2020/day24/testinput Normal file
View File

@ -0,0 +1,20 @@
sesenwnenenewseeswwswswwnenewsewsw
neeenesenwnwwswnenewnwwsewnenwseswesw
seswneswswsenwwnwse
nwnwneseeswswnenewneswwnewseswneseene
swweswneswnenwsewnwneneseenw
eesenwseswswnenwswnwnwsewwnwsene
sewnenenenesenwsewnenwwwse
wenwwweseeeweswwwnwwe
wsweesenenewnwwnwsenewsenwwsesesenwne
neeswseenwwswnwswswnw
nenwswwsewswnenenewsenwsenwnesesenew
enewnwewneswsewnwswenweswnenwsenwsw
sweneswneswneneenwnewenewwneswswnese
swwesenesewenwneswnwwneseswwne
enesenwswwswneneswsenwnewswseenwsese
wnwnesenesenenwwnenwsewesewsesesew
nenewswnwewswnenesenwnesewesw
eneswnwswnwsenenwnwnwwseeswneewsenese
neswnwewnwnwseenwseesewsenwsweewe
wseweeenwnesenwwwswnew

View File

@ -18,16 +18,16 @@ func (c Coordinate) Relative(t Coordinate) Coordinate {
return Coordinate{X: c.X + t.X, Y: c.Y + t.Y} return Coordinate{X: c.X + t.X, Y: c.Y + t.Y}
} }
func (c *Coordinate) North() Coordinate { func (c Coordinate) North() Coordinate {
return Coordinate{X: c.X, Y: c.Y - 1} return Coordinate{X: c.X, Y: c.Y - 1}
} }
func (c *Coordinate) East() Coordinate { func (c Coordinate) East() Coordinate {
return Coordinate{X: c.X + 1, Y: c.Y} return Coordinate{X: c.X + 1, Y: c.Y}
} }
func (c *Coordinate) South() Coordinate { func (c Coordinate) South() Coordinate {
return Coordinate{X: c.X, Y: c.Y + 1} return Coordinate{X: c.X, Y: c.Y + 1}
} }
func (c *Coordinate) West() Coordinate { func (c Coordinate) West() Coordinate {
return Coordinate{X: c.X - 1, Y: c.Y} return Coordinate{X: c.X - 1, Y: c.Y}
} }
func (c *Coordinate) NW() Coordinate { func (c *Coordinate) NW() Coordinate {

View File

@ -340,3 +340,17 @@ func IsPrime(value int) bool {
} }
return value > 1 return value > 1
} }
func Min(v1, v2 int) int {
if v1 < v2 {
return v1
}
return v2
}
func Max(v1, v2 int) int {
if v1 > v2 {
return v1
}
return v2
}