もしも
list_1 = [(1, 1), (1, 3), (1, 4), (2, 2), (2, 3)]
タプルの要素を (i, j) として考えます。(1, 3) が存在する場合、(1,1) と (1,2) のいずれかが欠落エラーが報告されます。エラー検出は、最初に (1,1) に対して、次に (1, 2) に対して 1 つずつ実行する必要があります。同様に、別のシーケンスで (2,3) が存在することがわかっている場合、同様に (2,1) と (2, 2) が存在します。
これもリストの例です。例は次のようにもなります。
list_1 = [(1, 3), (1, 4), (2, 2), (2, 3), (3,1) (3,4)] この場合、(3, 4) が存在する場合(3,1)、(3,2)、および (3,3) が存在する必要があります。このパターンは、各 'i' の j 番目の要素の最大値によって決定できます。私のコードは gi です。
for i, e in enumerate(list_1):
i1 = (1,1)
if i1 not in list_1:
raise ValueError, '%s is missing in %s' %(i1, production)
if (e[0] == e[1]) and ((e[0],e[1]) not in list_1):
#if i1 not in list_1:
raise ValueError, '%s is missing in %s' %((e[0], e[1]), production)
print e, e[0], e[1], (e[0], e[1])
if i!=len(list_1)-1:
if e[0]==list_1[i+1][0] and e[1]!=list_1[i+1][1]-1:
raise ValueError, '(%s,%s) is missing in %s ' %(e[0], e[1]+1, production)