Browse Source

day24: add haskell solution

main
Xiretza 1 year ago
parent
commit
739a3ff173
Signed by: xiretza
GPG Key ID: 17B78226F7139993
  1. 5
      README.md
  2. 2
      data/day24.expected
  3. 558
      data/day24.input
  4. 33
      day24/day24.hs

5
README.md

@ -25,5 +25,10 @@ https://adventofcode.com/2020/
|17 | | `**` | |
|18 | | `**` | |
|19 | | `**` | |
|20 | | | |
|21 | | | |
|22 | | | |
|23 | | | |
|24 | | `**` | |
`test.sh` can be used to run all solutions and automatically compares them to (my) puzzle inputs and the expected outputs.

2
data/day24.expected

@ -0,0 +1,2 @@
512
4120

558
data/day24.input

@ -0,0 +1,558 @@
nwwnwnwnwsenwnwenwenwnwnwnwnwwneswwnw
nenewsesweeeeeeeeeeeeneeee
swswswseseneswseswnwseseseseswnewseswsesw
swseseseeswsesesesesesesesesesenw
wnenenwnenenenenenenesenwnenesenenenene
esesenwseewseseseseseeseseeesweseese
eseeeneeeeeeeeeweeeswewe
seeseeswnweeneswwswneweeseenwsee
nenwneswneneeenenewneneeneneswnwnene
enwnwwnewnwnewwsewnwnwnwnwswnwewnw
neneneneswnenenwnwnwnenene
seseswesenwnweenwseseseeneeesewsesw
eeseswsenweneeeswneseenwseeewse
nenwneseeeneneene
eeneswnweseeeeeeneenwee
nwnenenesewnwseswwenwnwnwnwnwnwswwnwnw
swwswwwnwswwwswwwwwwewewsww
wwsewnewwwwwwwswwwwwwww
nwwnwwnwswneswwsewwnewsesenewnwe
eneeswseeeeeeesweenewewene
swewswnwnwswwwswsewwwwwswswwsww
swwneseseneswseseweswnweswwswesese
eneneneeeneneeeesweeewenenee
wseeseseseseseeseeseseseseewsesene
sesenwswswnwswseeswsweswnwswwswswnwse
eeenwseeenweeseeeeeseeeswsee
eseewseneswseeewsewswnwnweenee
seeeseesenwseseeeeweseesesesee
neseenwneneneneneeewneweneswnenww
wnewseswswswseswseesewseswneswswseswsw
wswenwsenenweseswnwewnwe
swwswseswnwswnenesesewenesenesewneswsw
nwnenwnewnwnwnwnesenwnwswnwnenwnwsenwnw
nwnwnwenwnwnwnwnwnwswnwnwnw
eeeeseseswseseeeeeneswseeeneee
ewwwwwsewwnewwwswwwwwwsww
wswwwwwnwseewwnwenwnwnwnwnwne
wwwenwwnewswewwwnwwswwwww
senwnwseesenenwnwesw
sewswwwwwwwwwwwwwwsenwwnew
neneeeewneeeneeeseeneeeenee
neeeeeseeeseswenweseeeenwee
eeeeeeneeneneswweeeeeene
seswwswswneswswswswswswswswswsw
nenwsenenesenenwnwnenenwneswsewsenewnenene
seswnwsenwswswswswswswwseswswswnewswsww
senenwnenenenenenewneenenenwnwnewnenwnwnw
wnwnwnwnwnwnwwnwnwenwwswnwnwnwnwnwnw
ewswwwswswwswswwswswsw
nwnwnwnwnwnwnwsenwnwnwnwnwnwnwnwnew
nenenenenenenenenenwnenenenenenwswswnenene
nwnwswwseneseswweswswswswswwnewewe
eneeeswseswneswenewnwwee
neswnwnenenwesewnesenwnwnwnwswneneneenw
seseswesesesesewneswsesesesesesewsese
wwwwswwsewwwswswnenewwww
wwwwsewwswsewnenwww
sewswseswseswseswswnwswnwswswwnwwswnww
esenwnwenwnwnwwnwnenwnenewnenwnwnwne
nwnwwnenwseenenwnwnwewnwnwnwnwnwnwnwne
swnwnwnwnwnwnwnwwnwnwswwwenwnwnesenw
swswswswnwseswswswswwswswneswswswswwesw
wsewenenwswnwnweewswwneswenesww
swwwswwswwswswnewswwsewwwwww
nweesweeeewseneeenee
wwwwnewsewwwswewwwwwnwww
seseseseseswsesewnenwswnwswswswnwswsesese
swseswseseswswsewseswswswneneswnwesesese
wneswnwneneneneseneneneneneneneneneenenwnw
neseseesenwseseeseseswsenwseesewsee
wwwnewewwwwwwwswwwwwswe
weeenwweneswneseneeeseeneneee
nwnwseseweswswswswseswseswneseswswsenese
seswenewneswseewnwww
eseswneseswseswswwnwse
nesweeneneseweeseeeeweenwwee
seewseenwwnesenesewswwwwnwwnwseene
nwnwwnwnwnwnwswwnwnwnwnwnenwnwnwnwesw
wnwwwnwnwnewnwnwnewnenwnwsesewsesw
nwswswsesweswwewwswnwwsewswnewnesw
swseewseseseneeseseneeeseseseseew
seswswseseseneswsewseseneswseswswwswsw
wwwnwwwewnwwwwwswwwwwnww
nenwnenewnenenenwwnwneneeneneenenenenw
nenwnwnenenwnwneneswnwswnenenenenenwnwnwne
nwnenenwneswneneeswnwnenewenwnwneene
nwewnwnwseenesenenwwswnenenwnwnenwnw
wnwwnwsewnwnewwwwewwwwwnwww
wwwewnewwwwwewnwswwnwwwwwse
senweesweseseseeeseeswenweeeese
swnenenwnwnenwnwnwnwswnwnwnenwnwnwnwnenw
nwenwnewwnwnwenwnw
swnwnenwswneneeneeneee
seseseswseseseseseswseneswswwesesesesese
seseseesenwsesenweseeseweeseseseswse
eeneeeeeeseeseseseswseeee
swswwswseneseseswseswseswnwwswswnwswsene
wesewwewwwwwneswswnw
nweewnwwsenwnwnwwnwwnwswwnwswnenw
eeeweeewseseeseseeeeesenwne
wsenewwwwwwwwnwwsewwwnwne
seewswnwnweeenesweseswseneesewe
swnewnewseneswweewenwwweswswnw
swweswnwswwnenwwswwwsenewnenewew
nwnwwwewnwsesewnwsww
neweswwnwnewswnwwewswneseewnwnw
swnwnwnwsewnenwnwnewsenwnwew
neseesesesesesesesesesesesesesewwsesewne
swwwnewnweeneswswseeswenwseswneswne
swnewsesenenwswsewsewnwwewnwwnwe
neseewseseseeswswsesenesenwsesenwseswse
swswswswswwswswseswswswswneswsweswsww
swwsweneswseseseneesesenwnwseeesesee
sesesesesenwseseseswnwswseseseesesesesesw
wwenwwsenwwwenenw
nenenwnenenenenenenesenenenenenenenene
swseseseseenesesenwsese
swsweswsesesesesesesesesesenwwse
seeeswswnweseneneswwnwsweneweenee
nenenenwnenenwnwnenwsenwnenenenenwsww
enewsesewseswsesewseeweseneenenesee
eseswswseneswwswnwseseseewswwwneseswe
eeeneseseeseeseweeeeewese
nwswwwwwwnwnwwnwewwwnwwwnwnwe
swswseswsesweswneswwswwnwswnweneswswne
sweeeneeeeneeeesweeeneneee
neneeneneneneswnenenewneneneeneeneene
swwnwnwnwwnwnwnwnwnwsenwnwnwnewsenwnw
eeeeenwseeseseeewseseseswseeee
wwnwwwswwwnwwwnenwewnwnwwwww
enenwseneneneneneeneneneeeneene
eseswwswwsewswswswwwswwwnwwwnewne
eeeneswnewswsesenwwsenenesesenwee
senweseeseswseseseseseseseseseseseese
swneswwwswswswswwwwswwswswseswswnwsw
swswswsewswneswwswswwwswswnwwwwesw
eweewnesenwnwwswswnweseseeneese
swsenewnewneneneseneneneneneenenenewene
nwnwweswwwswwwwnwwswwweswesw
neneneswwnweeeweswneeswneswwsenwnww
nwswsweswnwnesenwnwwswneeswswwesese
nenwnesesenewesewnwnenenwwsweeww
swswswswswswwswnwnesweswswswesw
wwwnwenwnwnwewwwnweswenwnwneew
nwwwnwnwnwnwnwwwsenesenwnwnwnwwnwwnwnw
eneneseseeesewenwsesesesweswsesese
seswwswseseseseswswseneswseswswsesw
swewswswwsweswswswswswswswwswswswsww
wnewneenesenenenwnewnenwnenenesenwnenenw
seswseseswwwsesenesesesewseewseswnene
eeneswneneneeneneeneneeneenene
swswswswswswwswswwesw
wwwswswswswswewswnwswwwewwsenwsw
eseeeesenweeeeesewseeeseee
swswwswwwswswwneswsweswswswswswswsww
seseenwseseswswsesesesw
newsweeewnwenewnesewsewnewnene
nwnwnwnwnwnwnwswnwnwsenwnwwnwnwnwnwne
sesesesesenesesesesewswseseseseswsesese
seseseseseseeseswsesesesewsesese
wwseswnwseswswnewwswwnwswwswwew
sewweswseseseseseseswseseseweneseswsw
nwnweneewnwnenwswswnwnenwneswnwwenenw
swnwnwnenwsenwnwsenenwnenenweswswnwnenee
seswseneneswsewewwnewnewwnwwwnesw
seswswsenwswswswswswswseseswseswsenesesewsw
senwseeseneseseseewseseseswweesesew
seweswsesesesewnwnweseseeswseneseswse
eeseeseeeeweeesee
swwswwnwwwnwwwwwnewsewwewwswe
nesenwneswenenenwnwwnenenwsenenesesenew
wenwswseseseseswseeseswwneseesenwse
nwneenwneseswenewsweseseneswenwee
seeseseseseneseseseseseseenwsesesesesew
wnenewneneneeenwenweneswswswseswnwse
wwwswwsweswswwwswswswsww
eeeweeseseeeeeeeenweeene
eswwwswsewnwwswnwewwswwwwwwsw
enenenwneneeeneweneeneeneseswee
wswwsesweswwenwewwswnenwnwswnewew
seseenwwwseswswneswneswsewneseeswnee
swneeeeneneswnwesweeeneeenwene
neneswnwwseeswseswseneesenwswswwnwswese
seseseswseseseseseseenwsenwseenewnwsewe
wneswweseswseswsesesesesesesese
seseeeseswseseseseseseseseseesenw
nwnwsenwsenweeseewesesweseswseswe
wneweswwwwwwwwwwwwwswwwsw
ewwswseesenweenwnwneneeese
sesesesesesesesesewseneesesese
swswswswnwewswwswswswswswswsw
nenenewwnesewneneneeneeneneeeeenee
senenwewnenenenenenenenenenenenwnwnenesw
swwsewswwswenwswnwsweswswewswnenw
swswswwnwswswswwswwwswwwswwswesw
seweeeeneeweeswseewnweeeeese
nwneeseeweenwswswseeeenwseenesw
wwnenesenwnwsenwnwnwnenwwenwnwnenene
eseeeenweneswesesw
swsenwwwnenwwswsenenenewwneswnweww
newnwnwnwnwnenenwsenenwnenwnenwnenwsewnw
eeseneenwsweeneenwnwnwnwsewnesese
eneseneneenweseneweneeeesewnenee
wswswswneswswswseswswswswswswswswswswsw
swswswenwneswswwswswswswseswswswnwswse
wesewseseeseseeeeseeseseeeesee
senwswsesesesweweenewswswswnenwsenwese
eseeeeeeeeewneeseeeewseeese
wwwwewswwwnewwwwwwswnwww
nwseseseswseseseseseswnwseseswswsesesesene
enweenewneseeewneeseeenwesenew
nenenewenweswnwneeneweseseneswneee
ewwwnwwwwwsewwnwwwwnwwwsww
neneneseswnewnenwnwneneswnweswwsenwswne
nwnwnwswnwwwnwnwwswnwwnwnwnewwwe
nenenewneewneeseseneenenenenenenw
nwnwsenwwwnwenwnenwnwwwsewwwnwsw
nwnwwwnwenwwwnwsewnwnwwnwnwnwnwnww
sewswswswswseswswseseswswswseswswswsene
wsenwnweswnwswewswnwnwewwsenwwnwww
swswneswneswwswwwwswswnewsw
wnenwnwnweneneswwnwenwneneneseseswwnw
nwnwsenwnwwnwsweswnwenwwnwwnwwnww
sweeeeneseeesewenweesweeee
nesewneneneneswneenewnesewsenenenewne
ewwwwwwenewenwwwwsweseww
nwewnwwswwwnwnwsewwwnwnwwwwwnw
seseeeneswsewseeseeeseneswsesenenw
senweswnwnenenenwnwswnwnenenw
nwswnwswnwnwnwwnwwnwwnewnewwnw
swswseweswwswswswneswewwwwswwsww
eeeneneeeeswnenwneesweeneeeeee
swswswswsweseeseswsewswswnwseswswseswsw
neseseseseseseseseweswseswsewswsese
nwwseswwnwnwwnenwwnwswwenwwne
ewsweseneeewneeeeweeeseneeese
seeswneseneenwnwewswnweseseswnwesese
eswswseswswswseseseswswnwsw
nwesesenweseeeseseseeseseswseswee
nwnwswnwwnenewnwnenwswnwswnwwwwnwnwnw
enweeswneeswweenwewseeseswsese
wwnwswswwwwwwwswwwneswwseswwe
nweeeeeeeeeeseeeeeeeesw
eseenwsenwseeseseenwwseswsese
neeeeseeseswewsenweseseeeeseesee
wwswswneseswswesweswswswnwseswswswesw
neeneneeeeeweeeeeneswwe
seswseseseseswseswswswneseseswsese
newwnwnwswnwwesewnenwwweswwwnw
nenwneneneneneneswnewesee
wswwwwwwwwswswswwwnewwwsw
nwswswseseswewseseswseswswswswsesesw
eeeeseseswsesesesesenesewewsesesenw
nwnenwseswnwnwnenenwnwewnwnenwseenwwnw
seswwwwwswseneenwneswswnenwsewswe
seswsenwseswseseseseeseseswneswwswwsese
swneneneneesenwnenwnenenenewseswnenenee
nwswnwwnwnwnwswnwsenesenenwnwnwnwnenwsenw
nenenwnwwnwnwnwnwnenwnwnwnwenwnwnwnwsw
neswwsewneneneeneneneeneeneneenee
seseneseswswswnwswswswswseswswswswwesw
nwnwnwenwnwnwnwswswenwnesenwnwnwneneswnw
enweeneeesweeeneeeeeeeee
seseseneseseswsesesesesewseseswsesenesese
seseswswnwneswswwswswseswseswswseneswswesw
seseseseseseswseeeeeeeeseseenw
eseenweseeenwesweeeeeeeese
seewneeneeeeneenesweenenwneeene
nenwnweenenwswsewnwwwsewnweneewnw
eseseseseswseenwesesesenwseseesesesese
wswswswneswswsweneswwswwswnwswsw
wwwwwwswwwwswwseenewsewnwnw
seseeesweenwseseswseeseeseesesesenwse
nenwnwnwneswnenenwswseeeswswneneneseww
swwwswsewwswswwneesenwswsewnenww
wnwseseseseseenwsewneenweseseeswsw
enwnwnwnesenwnwwsewwsesewnewwwswe
nwnwwnwsenwwnwnwwewnw
seseneswseswwseswswseseswswseseseseswsw
nwnenenwnwnwnwnwnenenwnwnwnwwsenenwnwnw
weseeneneneneneswneeenenesenewenewe
wwwwnwnwnwnwenw
nwnwsenwseseseswsesenwsesweswswneseeswe
seseswsewseseneesesenwnwse
wswwseswswwwswswswwwswnwwwwwene
eneswnwwnenwwenweewsweeswnwnwswne
wwwwnwnwsweswwenwnweswnwnwwnwe
nwseswswnewsesewnweswneseenesenewew
swnesweewwswwwswswnwswsewwwwnw
neeswneswnwsesenewneneswnwnewnwnenwne
swswswswseswswswswneseswseswswswsewsesw
swseneswswswneswseseswswswseseseswswsese
swswswswswwnwswnesweseneseswnweswswsesw
wnwwwwnewsenwswsenwwwwwnww
seseneswswswswsenwswswseswseswswwsweswswse
enwweeeseeeseneeneeeneneenee
seeeswseeesenwesesewseseeseesee
sewwnwwwwwswswnwswseewwewswwnew
swwsweneneswswwswneswwwwswseswswswsw
nwswseseseseseseseseseseseneseswsesesesese
wswwwnwnwwswwsesesweneneneswwswwsww
newswwswsewwnenwwweseswsewnwswsenenw
swswswseseseseswseswnw
nenenenenweswneneneneneewneenenenesene
seeseneswseseseseseswsesewswswswswsese
ewwwnwswwnwwwnwenwsenwewwsesenw
nwswnenwnwnwnwnwnweenwnwswnewnwnenesenw
nwwswwwwswwswnesewwwswwwwwww
sewwswwnwwwwwwwewwwwwwwnew
wswnwwwwnesewnewwnewwwswseew
nwnewwewneswnwwsenwwesenwwnww
neneneweesweeneneenenenese
wnwwsewwwnwwwwnwww
nwswenwnwswwnwnwwnwenwnwnwnwwsewww
seseswesenwseseeesenwseseeeseswsew
enweeeseenesewsenesesewseeesew
ewnwnwseneneneswneneneneswneeneswnenee
seseseseseseewseseseseeneseseseesese
nenwswsenenenewwnwnesenenenwnenwneese
swenwnwwswwwswswwesenwwnewswsw
seewswseeesenweeweeneneewneeww
eseseseesenwseeseseseesesesewnwsee
neseneeseswseseswseseseese
swnewnwsenwnenwneenesee
nwnwnwnwnwnwnwnwnwnenwsenwnwnw
nwwseeswenwnenwwwswsenewnweewesw
swswswwswswswswswswswswwswwnwwneeswwsw
nwnwnwsenwnwnesewnwswenwnwnwwnwnwwnw
nenwnwseeneneswswswsese
eeneseneeneneenenwnesweeeeneenw
neneneswnwswneeeneeeneneneneneneenwne
nesweeeneneeeweweeneeneenene
eseneneeenwsenewnenenewseswnenenenwne
swnenwneenenenenenesenwenewnenenenenene
wwwnwnwwenwwwnwwsewwnwwnwnwnww
ewwwwnwwwewsewnewnwwswsewwnww
esenenwseeseseseseseswsewswe
weswswswswwswnewwwwwwwesewswswnw
wwswwswsweneewswswnwnewswwwwwww
nwneneneneneneeneneneneswwneneenenenese
neenwnenenwnwswnwnenenenwseneswnwswswnww
nwnwewnwnwwewwenwwswsesenewww
wwwwwsewwwwwwwwwwwwwne
wseseseseseseswseseseesesesese
nwnwswwnenenenenwnenenwnenwnesenwnwnwnenw
nwsesenwwwnwnwnwnwnwnwwwnwnwnwnwnww
nwwwwwnwwwnwswwnwewww
eseneeseeseseeenwseeseeneseswseesw
swsewswswseswswneswswwswswnwswsweswsw
wwnwwwswwnwwnewsewwwnwne
swswswsenwswswswwswswswswswsesweswswsw
swseswneswnwswswsweseswnewsweneswnwswsw
seeseseeeweewseseneseewseseee
eeswneeeneeeneenenenw
nwnwnwnwnwnwnenwnewsenwnwnwnwnwsesenwnenw
nesenenwswneeswseseneswswnwnwswnenwswnew
wwnwnwwwswwwsenwwwwwnwewwswne
nwnwnenwnwnwswnwsesewnwsenenwswnenwnenwnw
nesesewewneswswsenwnwseenwwnesweenwe
seswweweseeeeeenwneeswenesewe
sewwswwnwswswwswswswneswswwweswswwsw
seseneeseseseseeseswseseesenwesesese
nwnenwnwenwwnwnwnwnwnwnwwnwnwnwsewe
wwnweswsenewsweswwswswwnwwswwww
nenwnwneneneneneneswnenenewnenwnenesenenene
swnwnenwswenwneswnwnwwnwnwseneenwwnesw
sesesweswnwnwswsesesweswseswsewswswsw
enenwneneeeeneeneseeneneneeneswnwe
wnewwwwwwwsewswwnewwsewwnw
seswnesesesenesesenesesewswsesesewsese
wwwsewwneswwswwnewne
sesesesesesesesesesesesenwswseneswseese
eneneneneneseenenenwenwswneneneswnee
wnwwwsesenwnwnwnewwnwnenww
nwswnwwseewwwwwewswenwswnwswsw
swsesesenwseswswseswswsesenwswseswsesw
wwwwnewwswswwwwwswwww
sesesesesesewsesesesewneseneesesewse
esweeeenweeeeeeeeeeeee
wsewesesewseenwnwneeswswnesenesee
wswwnwweswswswwswswswswsenwswswsw
swnenwswnwsweseswenwnwwweswweewse
swnenwwwneswwwswwneswseswwswwsesw
neeeeneenwseeseeeenenewewee
nwnwnwnwnwnenwswnwnenwnwnwnwwnwnwenwnwnw
swneswswswseswswenwneseswswseswswswswsw
seeseseneneswsesesewneeseeeswseseeswne
nwnwnewsenwenwswnenwnwnwnenwnenenenwe
swneswneneneenwneneneswenenenwnenwnene
neswseswnwnenwswnenwnewneswwswnwnwnenwnw
neneneseswneseenwnenenewwwneneneenwne
newsweswnwswneswsweswwwswswwsewsww
ewenweseeeweeneeeneneseswee
wswseswswnenenewswswsewswswewseew
nweneeenwwswsweeeseneseneeewne
senwwsweswnwswswsenwsewseswnwneeswe
swseswwewwnenewswswwnwwswwswsenew
eenenenenenenwnenwswswnwsweeeenee
neneneeneneeneneeneneneneesewneene
swnwwnwswswweswswswswswswswwseswswwsw
wwwnwnwnwwwwwswwwwnwnwnwsenwwne
wwswnenwwnenwwwewwwwwesesew
eeeeewseeseneseseweseeeeese
nwseeeseseeneeeeseeseeseeewe
eswneeneeeneneweseeneeneneeee
wnwswswwswsesweswswswswnwswswswwswsw
enwneneneswneneneneneenwsenenwnesenewsw
swnwnwwswnwwnwwwwnwnwwwsenenenww
wnweseswnwnwwnwwswnwnwnweeenwenwse
nwnwswnwswnenwnenwnenwenwnwnenwnwnenwnw
seseeseseseneseenwswneseseswnwsweneswwe
swwwwwwnwnwwwnwswnwwwnewewwne
eneneneswneneneneenenwnenenene
nesewsesewneswnwwwnwwwwwwnewwnenw
enenenwnenenenenenenesenenee
seswseswswswesenwseseswnenwswneswswswsw
nenenenenenewwneneenenenenenenesenenene
swneswnewswwwwswswswwwswswseswwsw
nwnwewnwnwseeneswwswnwnwwnwwwnwnwnww
eeeswnweeeweweweee
enwwnwwenwwsww
wneswsewswwwwwswwswwwswwww
swwwwewnwwweweswewwenwww
wwseswenewwwwwwwwwwsewnwwww
nwsewseseneswesweseswnwwswnew
swneseswswswswswswswswseswswswswswswsene
nwneneneneswneneswnenenewnenenenwswenene
wwswwewswswswswswwwswnwwwwseswsw
nweeseeeeseseeseesweseenwsesene
wneswswneneneenenenesesenewenww
seswneeneenewseeneenenenweneeene
neswewsewnwnenwnwnenwnwesewneneeswe
eeeeenwseeseseeeseeee
ewnwseeseseseeesenweseneseseseseese
swwneswewwnwwewwwwsewswnewww
swwswnenwesewneseenwswenewnwenww
nwnwwnwnwnwwwnenwnenwwnwsewnwnwnwsw
swnwswswswwswwswwnweswswswwswswswwe
wnwneeeeneneeesesweeeeeenee
ewnwneenwnenwnwnenenenwneneneneswneswnene
wwwenwswwnewwwweswwwww
swseenwwswswnwnwswsewseswswseneeesw
swneseseswswswseseseswswseseseswsw
neneneenwneneswwnwnenwnesewnenewnwnee
swnwswswseswseseswseswswswswnwseswswsesese
wswwswwwwswswwswsweswwswswnwww
nwnwwneseseneenenenenenwwneswnwsenewne
wnwsenwwwwwnwwwneswwwwwnwnwnwe
swswseswneseswswsewswswswswswswswseswnee
swsesewswnewnenwsenwneswneswwwswwsw
swseswswswsesesesewswseeseswseeswsenwsw
seswswwseeswswenwswseswenwswwswsesw
neneneneneneneneneneneswneweneneneneene
swsweneenwnwsweeeeenweeeeee
neswnesenwwswwnweeswsweswnesewsww
nwesewnwseewswswnwwswneeenw
eeseenesewsweseswnweseesenwnesesee
wneswswswnwswweswnwwsweswnweswswesew
senwnenenenenenenewnewnenenwnesenwneswse
nesenweswnwnenwenenwnwnwswswnwnwnwsenene
seswsweswswwwswwswwwwwwwswnewsw
enwwwswswswswswswswswwswwseswswnenwswsw
nwewwenwwwewwswswwwwwwww
sewseneswesweweeweenwneeesee
nwnwwwewnwwnwnww
seseseeenwswwenwswswseenwseseeseeee
seseswseesenesenwsesenwsesewsesesesesese
wwswwsesewswswwswwwenewswwswsenene
nenwnwesenwnweswnwnwnwwnwnwnwswnwsee
seswswswswswseseseenesewwsesenwsesesenw
wswsweswsenwwwwswewneswsew
swneneweswenwswswseswswseswnwsesewswesw
nwnenwsweesenwwseswenwwwseswwswnw
wwnwenwnwnwnwswnwnwnwnwwnwnwnwwnw
swswswneneenwnenwnwnwsenwenwnwwwnweenw
nwnwwnenwenwswnwnwnwswwenwnwneneswnwnwsw
enwnweewenesesweeneneeeeeene
nwenwweeeeeenwneeeswseeeswse
nwseneeneneeeeneeeneeeneenenenesw
wwneswswswewswsesenewwseswswnwswsw
swseswswswswseswsesweswswswswswnwswswswnw
nwweswwseseeseseneswnesenweseesenewe
wnenwnwnwnwnwwnwnwnwsesenwnwnwnewnwsenwnw
nenenenwnwsenenwnwnwnwnenwnwnwnwnwnwnwsw
ewsweenwnweneeeseneweseeesew
wnwnwnwswswswswswseeswswwswswseswswe
nwwswnwneeeeswewwnwswnwenwswswenwnw
swswswneswsewswswnewne
swsesesenesewswseseseseswseswsesesesese
nenewneneneneneneneeeneweneneeenese
wwwwnwwwwwwwwwwwwsewnew
wwswswnwswwweswwwwwswwwwsww
nwnwnwnwnwnwsenwenenwneswnwsenwnwnenwnwnwse
neneneneneneenenwneseneeenee
eeneeeeneenwswnesenenweeeeenesw
swnenenwseewnesweseseenwsesewseswnwse
seseswnwsesesweseneswsesesenwseseseseswse
nesenenwnwnwnwnenenwnewnwnwnwnwnwnwnwne
nenwnwwswnenwenwsenwnwsewnwnwnwwww
neswswseswseswswsesenwswswseswnwsweswswne
nweneseswnwnwnewnwneenenewnwnwnenwnenenw
eeseneeswswnweswseesesenwnesesesesee
eseseswswswswneswwswswneseswswwswwsw
seseseneswewsesesesesenesesesesesesesese
swsweewnwsewwenwsenenewnwsenenee
wnwwwnwnwswwwenwseeenwnew
swnenwneseseswswswseswswseeswnwseswswswswe
nwnenwwwnenwwsenwnwsenenwnwnenwnwnwnwse
swnwnwnwnenenenwnwnwnwseneenewnwnwnwnwnene
wnwewnwwswwwnwnewwwnwnwwswwwnww
nwsenenwnenwnenenwnenwnewnwseswenenwnwne
neneseeeneneenewneneneneswnene
sweeenweeseweseseesewseeee
nwswseneeeneenwneneeeswseneswenwene
nwnwwnwnenwnwnwwnwnwswwwnw
wwnwwnwwwnwwnwwwewnwnwswnwenww
wwwwwswwwwwwwswwnwwswswswe
seswneswsenwweenwswnwseeneneswseseese
nwswsenwwseswseswswsenwewenwnenwnwew
swnenwnenwneneneneneneswnenenwnenenesene
weenenenwneeneneeneseese
nwnwnenwswnwseesewneenenenewnwne
eenweswenwseeneeeeseeeeeeew
seswsewseseseswseseseswsenwseseswnesesese
seseswseseseswnesesesewseseseswswswsese
wswswwswneseswwswnwswswwswswwwwsw
swswswseeswwswswswseswseneswswswseswsw
nwnwnwnwnwnwnwswenwnwnenwnwenew
nwnwnwnwnwenwnwnwnwwwnwnwwnwnwnwnw
nwesweenweeeeseesweeeeeeene
nwwwnwnwwnenwnwnwsw
nwnwswwnwnwnwnenwwsenwnweswnwnwenwnw
seseseesweseeenwseneeeee
nweeswswesenenweneswnwenwneweneesw
eeseswswseswwneswwneseseswwsenwseswe
neeneeneneeeweeseneneneneseneneew
nwsewnwnwnwwnwnwwnwsewwnwnwnwnwnwwnw
wswswneswwnwswwswweswwwswwsww
sesenwswseswseswseseeswseswnwsesesesese
nwenwnenwnwwnwnwnenwwenwnwnwnenwnene
sewseewswnwenwswneenenwnwnenewsww
nenwnwnwnwnwnwnwnwneswnwswsenwnenwnenwnwnw
seseseseseswseswwseseseeswseswswewsw
neseneenwwwsenesesenenwwe
wwswswneneswnwsewswswswsewswswseww
sewewswwwnwnwsenwnwsewnwwnwsewwnw
wnwnwwwwwnwewnwwnwnenwsww
wwswswswewwnewswnwwwwnesw
swwwwewnewnewswnwwnwnwsewnesenw
swnwnwnwnenenweswenwnwnwnwnwnwnwswsenwsw
eneneneswneeeneenene
swswnwswswswsweswswswswswswswswswswnwswnee
wwswwwswnweswwwnwwwweweew
wnwnenenenenenenwnenwnenwnesenenenenwnesenw
nenweenwnwsewenwneseswsenwnwnwsesesese
wwneeseswseesenenesweneswneswnenwnenw
swswswwswwwwswswnwswwwnewwwwswse
seeseswswsenwwswswsesenwswswesenwese

33
day24/day24.hs

@ -0,0 +1,33 @@
module Day24 where
import AoC
import Conway
import Data.List
import qualified Data.Set as S
import Optics.Core hiding (Index)
import Optics.TH
data Coord = Coord { east :: Int
, northeast :: Int
} deriving (Eq, Ord)
instance Index Coord where
neighbours c = map (addIndex c . uncurry Coord) offsets
where offsets = [(0, -1), (0, 1), (1, -1), (1, 0), (-1, 0), (-1, 1)]
addIndex (Coord x1 y1) (Coord x2 y2) = Coord (x1 + x2) (y1 + y2)
parseSteps :: String -> Coord
parseSteps [] = Coord 0 0
parseSteps xs = case xs of
('n':'w':xs) -> go (-1, 1) xs
('w':xs) -> go (-1, 0) xs
('s':'w':xs) -> go (0, -1) xs
('n':'e':xs) -> go (0, 1) xs
('e':xs) -> go (1, 0) xs
('s':'e':xs) -> go (1, -1) xs
where go (e, ne) xs = addIndex (Coord e ne) $ parseSteps xs
main = runAoC (onlySet . map parseSteps . lines) length (length . conwayN 100 . S.fromList)
where onlySet = map head . filter (odd . length) . group . sort
conwayN n = last . take n . tail . iterate (update (==2) (`notElem` [1, 2]))
Loading…
Cancel
Save