Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Find Sequence solution in Clear category for Find Sequence by tssrkt777
from typing import List
def checkio(m: List[List[int]]) -> bool:
if len(m[0]) < 4: return False
for a, row in enumerate(m):
for b, x in enumerate(row):
# horizintal & vertical
if b 2 and len(set(m[a + z][b - z] for z in range(4))) == 1 or \
b < len(m[0]) - 3 and len(set(m[a + z][b + z] for z in range(4))) == 1):
return True
return False
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
assert checkio([
[7, 1, 4, 1],
[1, 2, 5, 2],
[3, 4, 1, 3],
[1, 1, 8, 1]
]) == False
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
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
print('All Done! Time to check!')
Oct. 31, 2021