def generate_zdestabs(self):
    distance = self.qecc.distance
    zdestabs_temp = []
    if ((distance % 2) == 0):
        b = 2
    else:
        b = 1
    for y in range(b, distance, 2):
        temp = []
        x = (distance - 1)
        for j in range(0, distance):
            new_point = ((x - j), (y + j))
            if (new_point[0] <= 0):
                break
            if (new_point[1] > (distance - 1)):
                break
            temp.append(new_point)
        zdestabs_temp.append(temp)
    zdestabs = []
    for ds in zdestabs_temp:
        for i in range(len(ds)):
            temp = []
            for j in range((i + 1)):
                temp.append(ds[j])
            zdestabs.append(temp)
    ladder = []
    y = 0
    for x in range((distance - 1), 0, (- 1)):
        ladder.append((x, y))
    for i in range(len(ladder)):
        zdestabs.append(ladder[:(i + 1)])
    ladder_points = []
    for i in range((distance % 2), (distance - 1), 2):
        ladder_points.append(i)
    ladder_temp = []
    for i in ladder_points:
        temp = list(ladder[:(i + 1)])
        (x, y) = ladder[i]
        for j in range(1, distance):
            if (j != 1):
                temp = list(ladder_temp[(- 1)])
            new_point = ((x - j), (y + j))
            if (new_point[0] <= 0):
                break
            if (new_point[1] >= (distance - 1)):
                break
            temp.append(new_point)
            ladder_temp.append(temp)
    zdestabs.extend(ladder_temp)
    set_destabs = {}
    relayout = {v: k for (k, v) in self.qecc.layout.items()}
    for d in zdestabs:
        row = set([])
        (x, y) = d[(- 1)]
        a = relayout[((((2 * x) + 1) - 1), (((2 * y) + 1) + 1))]
        if (a in self.ancilla_z_check):
            a = relayout[((((2 * x) + 1) - 1), (((2 * y) + 1) - 1))]
        for (x, y) in d:
            row.add(relayout[(((2 * x) + 1), ((2 * y) + 1))])
        set_destabs[a] = row
    return set_destabs
def generate_zdestabs(self):
    distance = self.qecc.distance
    zdestabs_temp = []
    if ((distance % 2) == 0):
        b = 2
    else:
        b = 1
    for y in range(b, distance, 2):
        temp = []
        x = (distance - 1)
        for j in range(0, distance):
            new_point = ((x - j), (y + j))
            if (new_point[0] <= 0):
                break
            if (new_point[1] > (distance - 1)):
                break
            temp.append(new_point)
        zdestabs_temp.append(temp)
    zdestabs = []
    for ds in zdestabs_temp:
        for i in range(len(ds)):
            temp = []
            for j in range((i + 1)):
                temp.append(ds[j])
            zdestabs.append(temp)
    ladder = []
    y = 0
    for x in range((distance - 1), 0, (- 1)):
        ladder.append((x, y))
    for i in range(len(ladder)):
        zdestabs.append(ladder[:(i + 1)])
    ladder_points = []
    for i in range((distance % 2), (distance - 1), 2):
        ladder_points.append(i)
    ladder_temp = []
    for i in ladder_points:
        temp = list(ladder[:(i + 1)])
        (x, y) = ladder[i]
        for j in range(1, distance):
            if (j != 1):
                temp = list(ladder_temp[(- 1)])
            new_point = ((x - j), (y + j))
            if (new_point[0] <= 0):
                break
            if (new_point[1] >= (distance - 1)):
                break
            temp.append(new_point)
            ladder_temp.append(temp)
    zdestabs.extend(ladder_temp)
    set_destabs = {}
    relayout = {v: k for (k, v) in self.qecc.layout.items()}
    for d in zdestabs:
        row = set([])
        (x, y) = d[(- 1)]
        a = relayout[((((2 * x) + 1) - 1), (((2 * y) + 1) + 1))]
        if (a in self.ancilla_z_check):
            a = relayout[((((2 * x) + 1) - 1), (((2 * y) + 1) - 1))]
        for (x, y) in d:
            row.add(relayout[(((2 * x) + 1), ((2 * y) + 1))])
        set_destabs[a] = row
    return set_destabs