Skip to content

Instantly share code, notes, and snippets.

@doubledare704
Created July 4, 2016 18:29
Show Gist options
  • Save doubledare704/35e66646c7d93fef4f6030cf460be650 to your computer and use it in GitHub Desktop.
Save doubledare704/35e66646c7d93fef4f6030cf460be650 to your computer and use it in GitHub Desktop.
Grid challenge of hacker rank
import copy
def checking_grid():
N = int(input())
L, iL, answer = [], [], ''
for i in range(N):
L.append(list(input()))
for idx,item in enumerate(L):
item.sort()
iL.append([inner[idx] for inner in L])
checkL = copy.deepcopy(iL)
for idx,item in enumerate(iL):
item.sort()
if item not in checkL:
answer = 'NO'
else:
answer = 'YES'
print(answer)
times = int(input())
for i in range(times):
checking_grid()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment