殻、12バイト
ルールの説明に応じて、11バイトまたは13バイトになります。
±Λ=;1Ẋ×≈mηfT
オンラインでお試しください!
入力は、スペースと0のみを含む行のリストです。単一の文字列が必要な場合は¶、プログラムの先頭に追加して行に分割します。TIOリンクは、明確にするために既にこれを行っています。出力は0または1です。偽の値や真実の値に問題がなければ、±削除できます。
説明
±Λ=;1Ẋ×≈mηfT  Implicit input: a list of lines.
           T  Transpose into list of columns.
        m     For each column,
         ηf   get list of indices of truthy elements.
              In Husk, whitespace characters are falsy and other are truthy,
              so this gets us the indices of 0s on each column.
     Ẋ        For each adjacent pair of these index lists,
      ×       for all pairs drawn from the two lists,
       ≈      give 1 if they differ by at most 1, otherwise 0.
              For each adjacent pair, this produces a list of 1s and 0s.
 Λ            Do all of these lists
  =;1         equal [1]? Return either 0 or 30 (length of the outer list + 1).
±             Signum; convert to 0 or 1.
考え方は×≈、(a)すべての列に正確に1つの0が含まれ、(b)それらの位置が最大で1だけ異なることを保証するために使用することです。例として、8列の入力を考えます
0  0  0 
 000 0  
  00   0
最初に、mηfTインデックスリストのリストに変換します
[[1],[2],[2,3],[1,2,3],[],[2],[1],[3]]
それからẊ×≈与える
[[1],[1,1],[1,1,0,1,1,1],[],[],[1],[0]]
それぞれが1最大で1だけ異なるインデックスのペアに0対応し、それぞれがそうでないペアに対応します。[1]両方のリストに1つのインデックスがあり、インデックスの差が最大1である場合、各結果は正確に等しくなります。