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0,0,0,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] from hashlib import md5 def finda(d): x,y=d[0],d[1]-1 return (x,y,'a') def findw(d): x,y=d[0]-1,d[1] return (x,y,'w') def finds(d): x,y=d[0]+1,d[1] return (x,y,'s') def findd(d): x,y=d[0],d[1]+1 return (x,y,'d') def find0(d,row,column): if d[0]==0: t=[finda(d),findd(d),finds(d)] elif d[0]==row-1: t=[findw(d),finda(d),findd(d)] elif d[1]==0: t=[findw(d),findd(d),finds(d)] elif d[1]==column-1: t=[findw(d),finda(d),finds(d)] else: t=[findw(d),finda(d),finds(d),findd(d)] tmp=[] for x,y,r in t: print("("+str(x)+","+str(y)+")") if maze[x][y]==0: tmp.append((x,y,r)) return tmp def get(o,O,row,column):
Road = [('', o)] while True: road=[] for (r_pre,d) in Road: if d==O: print('NSSCTF{'+md5(r_pre.encode()).hexdigest()+'}') exit() next=find0(d,row,column) for x,y,r in next: if len(r_pre)>=1: if 'ws'in r_pre[-1]+r or 'sw' in r_pre[-1]+r: continue if 'ad' in r_pre[-1] + r or 'da' in r_pre[-1] + r: continue road.append((r_pre+r,(x,y))) Road=road row,column=31,31 maze = [maze[i:i + column] for i in range(0, len(maze), column)] get((1,1),(29,29),row,column)
|