• # diagonals

I need some feedback ... I wrote that code a while ago and can't read it anymore.

```def checkio(matrix):
count = 0;
digits = []
# create set of symbols called digits
for array in matrix:
for elem in array:
if elem not in digits:
digits.append(elem)
#check for horizontal lines
horiz = find4(matrix, digits)
#transpose matrix to use same method again
transposedMatrix = transpose(matrix)
#check for vertical lines
vert = find4(transposedMatrix, digits)
#check for diagonal lines
stringBox = []
stringBox2 = []
stringBox3 = []
diag = findDiagonal(matrix, digits, stringBox, stringBox2)
diagT = findDiagonal(transposedMatrix, digits, stringBox, stringBox2)
return horiz or vert or diag or diagT

def transpose(matrix):
#stackoverflow transposed this
new_matrix = [*zip(*matrix)]
return new_matrix

def find4(matrix, digits):
count = 0
for symbol in digits:
for row in matrix:
for vector in row:
if vector == symbol:
count += 1
if count == 4:
return True
else:
count = 0
count = 0
return False

def findDiagonal(matrix, digits, stringBox, stringBox2):
length = len(matrix)
box1 = []
for item in digits:
for elem in matrix:
for e in elem:
if e == item:
box1.append(elem.index(e))
box2 = []
resultBox = []
length_subset(length, box2, stringBox, stringBox2)
anotherString = toString(box1)
#print(stringBox2)
for elemString in stringBox2:
elemString2 = str(box1)
#print('start')
print(elemString)      #TEST
print(anotherString)   #TEST
diag = seq_in_seq2(elemString,anotherString)
elemStringR = elemString[::-1]
#diagR = seq_in_seq2(elemStringR,anotherString)
resultBox.append(diag)
#resultBox.append(diagR)
return True in resultBox
def seq_in_seq2(subseq, seq):
if subseq in seq:
return True
print('TRUE')
else:
#print('FALSE')
return False
def seq_in_seq(subseq, seq):
#print(subseq)         TEST
#print(seq)
while subseq[0] in seq:
index = seq.index(subseq[0])
#print(subseq)
#print(seq)
if subseq == seq[index:index + len(subseq)]:
return True
else:
# 5432 is a False Negative in Assert Diagonal
return 0
else:
return False
def length_subset(length, result, stringBox, stringBox2):
if length < 3:
flatten_me(result, stringBox2)
return stringBox2
else:
newString = []
newString.append(length)
length2 = length - 1
newString.append(length2)
length3 = length2 - 1
newString.append(length3)
length4 = length3 - 1
newString.append(length4)
str1 = ''.join(str(e) for e in newString)
result.append(str1)
length_subset(length - 1, result, stringBox, stringBox2)
def flatten_me(listt, stringBox2):
ans = []
for elem in listt:
if (elem.__class__ is list):
for e in elem:
if (e.__class__ is list):
for f in e:
if (f.__class__ is list):
stringBox2.append((f))
else:
stringBox2.append((f))
else:
stringBox2.append((e))
else:
stringBox2.append(elem)
return ans
def toString(myList):
str1 = ''.join(str(e) for e in myList)
return str1
def findDiagonal2():
return False
'''
Test 11/12 (5x5)
False Positive 4321
This matrix is 6x6
011110
000000
440000
000021
443212  here
254345

test12/12
right result: true
2365628374
6959768516
6826193664
5832387464
2314512569
5487558495 eight
9799599812 eight
5174834188 eight
5332614388 eight
4814588747
'''
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio([
[1, 2, 1, 1],
[1, 1, 4, 1],
[1, 3, 1, 6],
[1, 7, 2, 5]
]) == True, "Vertical"
assert checkio([
[7, 1, 4, 1],
[1, 2, 5, 2],
[3, 4, 1, 3],
[1, 1, 8, 1]
]) == False, "Nothing here"
assert checkio([
[2, 1, 1, 6, 1],
[1, 3, 2, 1, 1],
[4, 1, 1, 3, 1],
[5, 5, 5, 5, 5],
[1, 1, 3, 1, 1]
]) == True, "Long Horizontal"
assert checkio([
[7, 1, 1, 8, 1, 1],
[1, 1, 7, 3, 1, 5],
[2, 3, 1, 2, 5, 1],
[1, 1, 1, 5, 1, 4],
[4, 6, 5, 1, 3, 1],
[1, 1, 9, 1, 2, 1]
]) == True, "Diagonal"
```
12