diff --git a/d12/P.png b/d12/P.png new file mode 100644 index 0000000..44cdc08 Binary files /dev/null and b/d12/P.png differ diff --git a/d12/Q.png b/d12/Q.png new file mode 100644 index 0000000..c819eb0 Binary files /dev/null and b/d12/Q.png differ diff --git a/d12/R.png b/d12/R.png new file mode 100644 index 0000000..df93bbf Binary files /dev/null and b/d12/R.png differ diff --git a/d12/S.png b/d12/S.png new file mode 100644 index 0000000..71e9cd0 Binary files /dev/null and b/d12/S.png differ diff --git a/d12/T.png b/d12/T.png new file mode 100644 index 0000000..940f7b5 Binary files /dev/null and b/d12/T.png differ diff --git a/d12/cmd.txt b/d12/cmd.txt new file mode 100644 index 0000000..6545496 --- /dev/null +++ b/d12/cmd.txt @@ -0,0 +1 @@ +pandoc -o fail.pdf -t pdf fail.md diff --git a/d12/fail.md b/d12/fail.md new file mode 100644 index 0000000..00f2890 --- /dev/null +++ b/d12/fail.md @@ -0,0 +1,34 @@ + + +I have only on patch of P + +![](P.png) + +\newpage + +So I have to choose this patch of Q + +![](Q.png) + +\newpage + +Then this patch of R + +![](R.png) + +\newpage + +then this patch of S + +![](S.png) + +\newpage + +But then, this patch of S is not connected to the patch of T + +![](T.png) + +I feel like i'm stucked :( + +But actually, [not](https://www.reddit.com/r/adventofcode/comments/zjqz5y/2022_day_12_is_my_input_invalid_or/) + diff --git a/d12/run.py b/d12/run.py new file mode 100644 index 0000000..1b786f1 --- /dev/null +++ b/d12/run.py @@ -0,0 +1,50 @@ +import sys +import networkx as netx + +M = [ list(l) for l in sys.stdin.read().splitlines() ] +H = len(M) +W = len(M[0]) +START = tuple() +END = tuple() +G = netx.DiGraph() + +for x in range(H): + for y in range(W): + k = (x,y) + v = M[x][y] + if v == 'S': + START = k + v = 'a' + if v == 'E': + END = k + v = 'z' + v = ord(v) + for dx,dy in [(-1,0),(1,0),(0,-1),(0,1)]: + nx, ny = (x+dx, y+dy) + if nx>=0 and nx=0 and ny", len(S)-1) +for (x,y) in S: + M[x][y] = "\033[30;43m"+M[x][y].upper()+"\033[0m" +print("\n".join("".join(l) for l in M)) + +# part 2 +R = [] +for x in range(H): + S = netx.shortest_path(G, (x,0), END) + R.append(len(S)-1) +print(min(R))