Skip to content

Instantly share code, notes, and snippets.

@exclusiveTanim
Created November 11, 2020 17:09
Show Gist options
  • Save exclusiveTanim/02cd787e40edf721e9fbfb1ade0ec1ba to your computer and use it in GitHub Desktop.
Save exclusiveTanim/02cd787e40edf721e9fbfb1ade0ec1ba to your computer and use it in GitHub Desktop.
Unexpected Out comes here :) :)
import numpy as np
from past.builtins import xrange
MyArray = np.array([[1,1,1,0,1],[0,1,1,0,0],[0,1,1,0,0],[0,0,0,1,0],[0,0,0,1,1]])
Myresult = 0
DataArrayIS = [[[0] * 4 for _ in xrange(len(MyArray[0]))] for _ in xrange(4)]
for i in xrange(len(MyArray)):
for j in xrange(len(A[0])):
DataArrayIS[i % 2][j][:] = [0] * 4
if MyArray[i][j] == 1:
DataArrayIS[i % 2][j][0] = DataArrayIS[i % 2][j - 1][0]+1 if j > 0 else 1
DataArrayIS[i % 2][j][1] = DataArrayIS[(i-1) % 2][j][1]+1 if i > 0 else 1
DataArrayIS[i % 2][j][2] = DataArrayIS[(i-1) % 2][j-1][2]+1 if (i > 0 and j > 0) else 1
DataArrayIS[i % 2][j][3] = DataArrayIS[(i-1) % 2][j+1][3]+1 if (i > 0 and j < len(A[0])-1) else 1
Myresult = max(Myresult, max(DataArrayIS[i % 2][j]))
print(MyArray)
print('The Results is Here:',Myresult)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment