09.apl
1 input ← ↑⍎¨¨⊃⎕NGET '../.cache/2021/9' 1
2 low←{w←⍵⋄⊃∧/{w<⍵}¨(⍉9,⍉¯1↓⍵)(⍉9,⍨⍉1↓⍵)(9,⍉¯1↓⍉⍵)(9,⍨⍉1↓⍉⍵)}input
3 ⎕ ← +/∊low×input+1
4 dfs ← {x v←⍵⋄(⊂x)∊v:v⋄⊃{~(⊂⍺)∊⍳⍴input:⍵⋄⍺⌷input≥9:⍵⋄dfs ⍺ ⍵}/(((x+⊢)¨(¯1 0)(1 0)(0 1)(0 ¯1)),⊂(v∪⊂x))}
5 ⎕ ← ×/3↑{⍵[⍒⍵]}{≢dfs ⍵ (⍳0)}¨⍸low