From 341b0687802302c5c3e00e1f808b853ec575c5f0 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Thu, 20 Dec 2018 23:33:30 +1030 Subject: [PATCH] Dodgy 2018 Day 20 --- 2018/day20-input | 1 + 2018/day20.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 2018/day20-input create mode 100644 2018/day20.py diff --git a/2018/day20-input b/2018/day20-input new file mode 100644 index 0000000..4bed316 --- /dev/null +++ b/2018/day20-input @@ -0,0 +1 @@ +^SENEENNNESESWSSWWSWWSWSESWSWSWWSWWSWNWWSESWWSEESSENEESSESSENENNNEESWSSEEESSSESENNWNEESSESWSEEESENESENENENWWSWWWWNNEEE(SWWEEN|)NWWNNENNNENNESESEENENWNEESEENNESSENEESSW(N|WSESENESENEESWSSSSSSWWNENWWWNWWNWSWNWWNN(WWSSWWS(W(NNEENW(W|N)|W)|SSEENWNEE(SSSESWSESSEEENWNENESSSSSSSSWSSSWWSWNWSWNWNNNENNWNWSWNWSWNNWN(EESENESENEN(W|ESSWSEESESWW(N|SEESWWWSEEEENNNENNNWW(SESNWN|)W)|N)|NWSSWNNWSWSWSSWWWSWSWWSWSEEEEN(EN(NESEESESWWW(NEWS|)WSESWWWN(E|WSWSWSESSENNEN(EEEENESENN(WW|EENEENENN(WSWSWNNWS(WNW(W|NNE(N|SENESE(S|N)))|SS)|EE(E|SSW(SESSSWNWN(N|WSSWN(WWSESSSWSWWNWSSWWNNE(S|NWW(WSESWWWSSWWSWNNWNWNWNEENNEE(NEN(E|WNNWWWSWWSSSENNEENESSWWSSWWWSWWNENWNNESE(NNWWNNWNWNEENNESEENNEENNWSWWS(S|WNNNNWNEEESWSE(SWEN|)EENESESSEENESEENESSWWSWSSS(ENNE(EN(W|EE(SWEN|)NWNENE(S(ENEWSW|)S|NWNNNWSWSWS(EE(N|S)|W(S|NWSWW(NNE(EEENEWSWWW|)(NWWS(S|WNWW(WNENWNWSSSWWNNE(NNNESE(NNNWSWNWSSWNNWSSSEESWWWWSSWWWSSEEN(W|EENESSSWNWSWSESENESESS(ENNNWNNNNNWW(EESSSSNNNNWW|)|WSESWWSSWNNNNE(N(E|WWWWWNNN(EESS(WNSE|)E|NWSWNWWNWWWNNENWWWSESSWNWWNENWNEENWNEEEESEENWNNWWWWWS(WNNENEES(W|EENENWW(WWWNEEEENENESENNESSSWSSSSEESENNNNESESSSESENE(NWNW(S|NNWNNWSWNNEENEESWSSENEENESSSWW(NEWS|)S(WNSE|)SEEN(ENNESSSWS(EEEE(S|NWNEESEENNNNESSENNNENNEESS(ENNNNWSWWNWWWSSES(ENNWESSW|)SWWWNNE(SEWN|)NNWWNNESEEENNWNEESESES(WWNSEE|)(ENNNENENNNEEENNESENEESWSSWW(NEWS|)WSWSEENEESESENENENWNEENEENESENNWWWNENWNEEESS(WNSE|)ESENNEESSSESWSEENESESSEENNNW(NW(WWNWNNEES(W|ENENEENESEENNESSEENENWW(NNENNEENWWNEEENWWWWNNESENEEENWWWNNNWNENWWWNWSWNNNWSSWNNWSWNWNNEES(W|EENNW(S|WWWWNWNNESEENESES(EENWNENWNNEES(SENNESEESSEENENNNNWNNNNWWNWSWSWNN(E|WWWWWWSSENESSSENENWNEESSSWSS(EEENW(W|NNESEENWNEESSSSWW(NEWS|)SEES(ENNSSW|)S)|WNWSWSWWNNE(ENNWSWWWWWWWSWWNWNNNN(WWSSWSWNNWN(EESNWW|)WSSSWWSEESSSSESWWWWNNNEN(ESSSWN|WNWWNENWNEN(EEESWWS(S|EE)|WWSWNWWSWWN(WWSSWNNWWWWWSWSEESEENE(NWW(S|W)|SESEEENESESSSWSESSEENNNW(NEEESWSEE(NNNWWNWNN(ESNW|)W(W(SESSEWNNWN|)WWW(SWEN|)N|N)|SSSESWWNNW(NEWS|)SSSSEEN(EENEESENEESENESEENENWW(NEENWNNN(EESEENN(WSNE|)ESEE(NWES|)SSWS(EE(NEES(W|E(S|NN))|S)|WSWWW(NEN(WWNSEE|)E(ENEWSW|)S|S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EENSWWW|)(S|NWWWWSSSSWNNNNNN(WWW(NEEEWWWS|)SWWSWNNWWNWWNENE(NNWSWNWWSSSWNNNNEN(WWSW(N|SESSSSW(SESSEESESEEENE(EESWWSWWWWSESWSEENEN(W|EENESSWWSWSESWWWWWN(WSSEEEESWSEENEN(ENNEN(ESEESWSSSESWWNWW(NEENWNE(WSESWWEENWNE|)|WSSSEEEN(WNWSNESE|)ESSSWSSWNNWWN(EEE|WWSESEESSWNWSWSSSSSEEENNESSSEENESSSWNWWSWWNN(ESNW|)WSSWSWWNWWNWSW(NNENWNEENNWSWNNEENWWNNNESEES(WW|SENE(ENWWNENWWW(SEWN|)NWNW(SSEWNN|)NEENESS(W|SEEENE(S|NWWSWNNNWWWSWNNNNE(SS|NNESENNWWW(NEEN(ESNW|)WN(W(NN|S)|E)|SS))))|SSWWSEESSSSESW(WWNENW(NENW|WS)|S)))|SSSSENEEESSSENEENWWNN(WWNWWSE(WNEESEWNWWSE|)|ESENNEESWSSEESWSESENESSSSWNWWSESEESESESENENNEEESWWSESEESWWWNWSSWNWSWSWNNWSSSSWWWWNNWWNNESEEENNWNWWWS(EESEWNWW|)WSSWWNWNNNEES(WSESNWNE|)ENNNNENESSENE(SSWWW(N|SEEEE(ES(E(ES(ESNW|)WWSSSSWNWS(NESENNSSWNWS|)|N)|W)|N))|NWNW(WWWS(E|WSWSW(NNNE(NWNEES(ENNWESSW|)S|S)|S(SSSSSSSSSENNEN(WNSE|)EESESE(SEESESWSWWWWWSSWS(EEENWNEEESWSEENEEES(WW|ENEEEES(ENNENWWNENNEENENWWSWNWSWSS(ENSW|)WNWNEN(WWSSSESWWNW(N(W|E)|SSEES(WWW(N|W)|EEE(NW(NEWS|)W|E)))|NE(S|EENEES(EEN(W|ENWNNNEESESW(WNSE|)SSSSSSSWNNN(N|WSSSW(N|WS(WNSE|)ESEEEEENEENNEEEEENENEEEEEEEESEE(NNW(NWWN(E|N(WWSWWSS(ENESE(NN|EE)|WWWNEENNWWWS(WNWWWWNEENNESES(EENEEE(NWWWW(S|WNWWNNWWNENWWSWSSE(N|ESWSS(SSSSENEEESWSSWWS(EEEENWNENESS(NNWSWSNENESS|)|WSSWW(SWWWEEEN|)NENWNEN(NN(WSSNNE|)NNNWNENWNNWNENNE(S|ENWWNNWWSSWSSSWNNWWSESWSWNNNNEEENWWWNWWNNW(SSSSEE(NWES|)SSSWSWNW(NN(EESWENWW|)WNNE(S|NWWW(NE(EE|N)|S(ESSNNW|)W))|SSSES(W|E(SWEN|)NEN(N|ESEEES(SSWENN|)ENEN(ESSWENNW|)WWW(NEEENNEN(W|NN)|W)|WW)))|NEESSEESENEE(S(S|W)|EENNNEN(EESSESE(NNWESS|)SESENESE(N|SWSESWWNWWN(EE|W(N(E|NWNWS(SSEN|WNNEN))|SSEESSESEENEN(EESESWW(WSS(WNWWEESE|)ENEESW|N)|WW(S|W)))))|NWWWSSSS(ENNNEWSSSW|)WWNENNWN(NWWWNENNWSWSWNNENNNWNNEES(E(SESWW(SEWN|)N|NNWWNENESENNNWWNNWW(SSE(S(W(WNSE|)S(SSWSSSSESWW(N|SESSSS(WNNNWNWSS(ESSSNNNW|)WWW(NEE|SSEN)|ENESESS(WWNEWSEE|)ENE(NWES|)S(SSWNSENN|)E))|E)|EE)|N)|NWWNEE(EES(ENE(SSS(WNSE|)EEES(WW|E)|N(WNNNEWSSSE|)EES(E(EE|N)|W))|W)|NWNWW(NENWNEEE(NWES|)SS(WNSE|)S|S(E|S)))))|W)|E)))))|E(EENSWW|)S))|ENE(S|NN))))|S(SEWN|)WW)|W)|EE))|N))|S)|SWSSEEESWSWNWWWSESE(ES(WWWNWWNENWNWSSWSS(WNNNENWWSWNWWWSSSES(WWWWWNEEENNNN(WSSSWW(NEWS|)WSSWWWNWWW(WSEEEWWWNE|)N(N|EEEESEN(SWNWWWEEESEN|))|EEEEEEENESEESEENNW(S|NWW(SEWN|)WWWWS(E|W)))|EEENWN(W(NWSNES|)S|E))|E(EE|N))|EEENW(NENNESENNESSESWSS(EEN(W|EES(ENNNNEENWNNWNN(WSWWSEESS(ENSW|)WWW(N(EE|NWWN(NNESE(SWEN|)(N|EE)|WWSSS(EN(N|EE)|WNW(SW|NE))))|SEEESWWSEE(WWNEENSWWSEE|))|ESESES(W|SENNNESSSSSSSWNNW(NEWS|)SWW(NEWS|)SSEE(NWES|)EEEENWNEENEEEEEESESES(ENNENWW(NEENWWWNEENEES(W|ENNWNWSWWSWNNENNWWNWWSSSEE(SSSSS(ESNW|)WWWWNWWS(WSWNNNNEES(WSNE|)ENESESENNN(ESSSNNNW|)W(NWWNENWNENE(SSS|NWN(W(N|SSWWN(E|W(N|SWSSESWWN(NNNEWSSS|)WSS(WNWWEESE|)(S|EEESEE(EE|NNNNW(W|SSS))))))|EEEENESEESWSS(EEN(NNEESSW(SSWS(W(S|N)|EEENWNEEESEEEESWWWWSSWSSW(SESSSEESWWS(WWWN(WSNE|)ENWNEE(NWWNEWSEES|)SS|EEEENENWNNWNENESENNNENESENNWWW(NEENEES(W|EENWNENWWWNNNNESSES(W|EESESSW(N|SSWWWSSENESEEENW(W|NNENESEEENESENNWWWSWNNNNWNNNNENENESSENNENNNEE(NWNENWNENNWSWNWWWWSSSSSSSEES(WWWS(SWWSSE(N|SWSWS(ESE(ESWSEWNENW|)NN|WNWNNWWNENNENWNENENNESSSENES(SSWNWW(SSWSEE(SSWNSENN|)NN|N)|ENNWWNENE(S|NNWWWSS(ENEWSW|)WNWSSSWNNWWNENWWSWWNENEENEENWNNNESSENNENNEESSESSWWN(WSSWSEENEESWS(WWSWW(N(W|E)|S)|EENNENWNENNW(NW(NNNWWSESWWWWNENWWSWNNNWWNNNWWWSSWNNNENWNWNWWNEENESSESESSEENNESEESENNWWNWWNEENWNEENNNNENESENNNENEEESWWSSW(SEEESWSWNWWWWSSSEEEEESSESWSEESENEENNESESWSSENE(SSSSSWNWWWSEESWWSWWNENNNNWN(WSSSS(ENNSSW|)WS(WWNENWNEE(NWNN(E(S|E)|WSSWSSSWNNN(N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NENNNE|W)|EEN(E|W))|N))|E))|S)|SWS(WW|E))|ESE(NNWNNNNNNEEENNESEEENEEEEN(EESESSWSESSEEESWSSENEN(NNWNEWSESS|)ESE(SWWSWWSEEESWSWSSWSEES(ENNWNEEE(NW(W|NENWN(W|EESEESWW(EENWWNSEESWW|)))|SSW(N|S))|SWNWWW(NNE(NENWN(EE|WWWNENESENNNWSWNN(EE|NWSWSS(WNWNENWWNENWN(EEEE(SWS(WNSE|)(EE|S)|N(N|E|WWWW))|WSWWN(WSWSESESEE(NWN(E|W)|ES(SEWN|)WWWWNWSW(SEEESNWWWN|)WNNNNESS(S|E))|E))|E(SWSSNNEN|)N)))|S)|SSESESSEN(NNWNWESESS|)EESWSESWWNWSWSWSEEESSEEESWSSSWNWSWNWWNNEE(NNWSWWWSESWSESSW(NWSWNWNWW(SES(W|E)|NEEENE(SSWENN|)NNNNENWNNEN(WWNNWWS(WWNWW(SS(ENSW|)SS|WNE(NWES|)EEE(E|S))|SE(N|SWSESSSSW(SSENENNNNNN(SSSSSSWENNNNNN|)|NNN)))|ESEE(NWNSES|)SWW(W|S(SSS(WNSE|)E|E))))|SEEEEN(WNWSNESE|)ESESENEN(E(NWNEN(NNENNNWW(WSW(NWWEES|)SEEENW|NENE(SEWN|)NWW(S|N))|W)|SSWS(EEE|SWWN(E|WNWSW(SEEWWN|)NWWWSEE(WWNEEEWWWSEE|))))|WW))|S(ENESNWSW|)W)))|N)|WNNE(N(NWSWWSESWWNNWSSS(EEE|W(WWN|SE))|EE)|S))|S))|NNWSWN)|EEENEENWW(WSNE|)NEN(NNWNEWSESS|)ESESS(EENNW(S|N(W|E))|SSWNWSS(WNSE|)ES(SS|W)))|W(N|WW))))|E))|W)|NENNESE(S(S|W)|NNW(NEESSE(NNNWWWNNNWWSW(SEENSWWN|)NNENNNNWWSS(WNW(WWNNWNNESESSEENNENNEN(WWSSW(NNN(NESNWS|)WWSES(W|S)|SS)|EESSW(N|WSEES(SENNENNENNWSW(SS|N(W|NNE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E(SE(N|S(ENES|WWN))|NW(W|N))|WW)))|N)|EEEN(W|N))))|NEE(SESEEWWNWN|)N))))))|W)|W)|EEE))|NWWSWNWNWWNEE(N(NN(N|E)|WW)|EES(W|EE)))|NNN))|N)|SE(S|N))|EEES(WW|ENE(NNEWSS|)S)))|NESSES(WSSSNNNE|)EE)|ENESS(ENNEN(NEENENNWSW(S|NNNWSWW(WNNNWWNWSWS(EEE|W(SWEN|)NNNE(ENNWSWWNWSWS(WWWS(WNWWW(SEEWWN|)NNWSSWW(SS|NENWNNN(ENEEN(W|ENESEEEN(WW|EE(SSSSS(ENESE(EE(NWWEES|)ESSSEEEEEESENNWWNNNNW(SSSW(SEWN|)N|NENN(WSWSWNW(ESENENSWSWNW|)|ESSSESENESSE(N|SWS(EENNES|W(NWWN(N|EE)|SESSSESESWW(SSESWSSSWS(S(S|ENESESENESS(WW|ESEES(E(S|NNWWNNNW(N(NWNENNEENNNES(SSSEWNNN|)EEENWWNW(NNEES(W|SENESEEE(NWWNEENNNWWW(NEEEEESES(ENESENNENWNEEESSEENWNNWWWWNNNWWN(NNEN(W|ESSWSEENENNESENNWNEEESEEEENWWNNEES(EENWN(WW(NENWESWS|)WWSWS(ESNW|)WWN(WSWWWW(SES(W|E(ENWESW|)SS)|N(WSWWNE|EE(NWES|)E))|E)|EESENENWNN(WSSNNE|)EEESW(SSENESEEEEENESESWWSSSENNE(ENE(S|NWNWN(WWWNWSWW(SEEEWWWN|)WNN(EESWENWW|)WN(E|WWWSEE)|E))|SSSWWWNNWNENWWWWWSEEESWSSENESSEEESWSWNWSSSSWWWNENWWSWSWNNNE(NNEE(EESS(WWWNEE|SS)|NWWWNNE(SENESNWSWN|)NNWSWSW(SSE(SS(ENSW|)SSWSWWSSWS(WNNWSSWW(SSSWSS(WNW(SS(SWSESW|EE)|N(W(SWNSEN|)NN|E))|E(E|N))|WNNWNEESE(SWEN|)NNNNWNEN(WW(SSWSW(N|S(EEENWESWWW|)SWW(SEE|NEN))|N)|EEES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N|)EENENWW(WWSEEWWNEE|)NN(EESWENWW|)N)|NWNNN(ESSNNW|)W(WSESWWNNW(ESSEENSWWNNW|)|N))))|N)))))))|S)|W))|N(ENWESW|)WW))))|ESSSWN)))|E)|N))|ESWSWN)|SWSEEN)|S)|N)|NN)))|WSSSWNWSWW(SS(WNWSWNW(W|S)|ENEESW)|NNWNNN(NN|ESSES(S|EENWNWNENE(SSEWNN|)NN))))|S)|W))|SS))|E)))|ESENEEESSS(WWN(NESNWS|)WS(WNSE|)S|EEEENWWWNEN(EESWENWW|)W))|S)))|W)|WWW)))|S))|S)|SS)|S)|W(SESWW(SS(WSWN|ENE)|N)|N)))|WW)|W))|SSWWS(SWS(WNNWSWSSS(ENNSSW|)WWNWNENN(WSW(SSWENN|)NWWNWS|NNE(SE(SWSSSNNNEN|)NEE(NNN|ES(S|WW))|NWWNN(NNNWESSS|)W))|E)|EE))|S))|EEEE)))|S)))|ESE(N|SES(EE(N(W|N)|E)|W)))|S)|S(E|S)))|S)|S)))))|S)|WSWWNENENNN(E|WWW(SES(ENSW|)WS(WSS(ENSW|)WSWNWSWNN(NEES(W|ENNENW)|W)|E)|NN))))|S))|SWSEESSW(SEWN|)NW(S|W))|NEEEEEESW(S|WW)))|N)|E)|N))))|W))|W)|WW))|NN))|EES(ENE(NWWN(WSWENE|)EE|SE(N|ES(W|ENEESSW(N|W))))|W)))$ diff --git a/2018/day20.py b/2018/day20.py new file mode 100644 index 0000000..1e48556 --- /dev/null +++ b/2018/day20.py @@ -0,0 +1,29 @@ +with open('day20-input', 'r') as file: + data = [l.strip('\n') for l in file] +input = data[0][1:-1] +from math import inf + +directions = {'N': 0-1j, 'E': 1+0j, 'S': 0+1j, 'W': -1+0j} +stack = [] +distances = {0+0j: 0} +pos = 0+0j +next_distance = 1 +for c in input: + if c in directions: + pos += directions[c] + distances[pos] = min(distances.get(pos, inf), next_distance) + # This doesn't account for potentially shorter distances to other rooms along the old path to this room. + # Works for both parts on this input though so no gain in fixing v(ツ)v + # Backtracking those nodes would require keeping track of doors vs walls etc. + elif c == '(': + stack += [pos] + elif c == '|': + pos = stack[-1] + elif c == ')': + pos = stack.pop() + next_distance = distances[pos] + 1 + +print(max(distances.values())) # Part 1 +print(len([x for x in distances.values() if x >= 1000])) # Part 2 + +