Created
July 4, 2016 18:29
-
-
Save doubledare704/35e66646c7d93fef4f6030cf460be650 to your computer and use it in GitHub Desktop.
Grid challenge of hacker rank
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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