We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#!/bin/python3importmathimportosimportrandomimportreimportsys# Complete the solve function below.defsolve(board):res=[]p_el=Noneflag=Falseforiinboard:count=0prv=Noneforjini:ifcount==0:ifj==p_el:flag=Truebreakelse:p_el=jcount+=1ifprv==j:flag=Truebreakprv=jifflag:res.append('No')breakifnotflag:res.append('Yes')returnres[0]if__name__=='__main__':fptr=open(os.environ['OUTPUT_PATH'],'w')t=int(input().strip())fort_itrinrange(t):n=int(input().strip())board=[]for_inrange(n):board.append(list(map(int,input().rstrip().split())))result=solve(board)fptr.write(result+'\n')fptr.close()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Customized Chess Board
You are viewing a single comment's thread. Return to all comments →