Misc
sudoku_easyimport sys def read_file(textfile): f=open(textfile,'r') next(f) i=0 j=0 matrix=[[0 for x in range(9)] for y in range(9)] #print(matrix) while True: j=0 char=f.readline() for c in char: matrix[i][j]=int(c) #print(i,j) j=j+1 if j==9: i=i+1 break if i==9: break return matrix def check_soduku(row,column,number,matrix_board): check=0 for i in range(0,9): if matrix_board[row][i]==number: check=1 for i in range(0,9): if matrix_board[i][column]==number: check=1 row=row-row%3 column=column-column%3 for i in range(0,3): for j in range(0,3): if matrix_board[row+i][column+j]==number: check=1 if check==1: return False else: return True class calls: number_of_calls=0 c = calls() def sudoku_solver(matrix): c.number_of_calls=c.number_of_calls+1 break_condition=0 for i in range(0,9): for j in range(0,9): if matrix[i][j]==0: break_condition=1 row=i column=j break #print(matrix) #print(break_condition) if break_condition==0: print("Naive Backtracking Algorithm Solution: ") for i in matrix: print(i) print("Amount of Recursions") print(c.number_of_calls) exit(0) #print("hello") for i in range(0,10): if check_soduku(row,column,i,matrix): matrix[row][column]=i if sudoku_solver(matrix): return True matrix[row][column]=0 return False matrix=read_file(sys.argv[1]) sudoku_solver(matrix) #print("'''''''''''''''''''''''''''''''''''''''''''''''''''''''matrix'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''") #print(matrix)sudoku_speedrun
import telnetlib import sys fuck = [] def move(noooo,jie,tn): x1=0 y1=0 print(jie) for y in range(len(noooo)): for x in range(len(noooo[y])): if noooo[y][x] == 0: if x > x1: for d in range(x - x1): tn.write(b'D') else: for d in range(x1 - x): tn.write(b'A') x1 = x if y > y1: for d in range(y - y1): tn.write(b'S') else: for d in range(y1 - y): tn.write(b'W') y1 = y tn.write(str(jie[y][x]).encode()) print(tn.read_all().decode()) def check_soduku(row,column,number,matrix_board): check=0 for i in range(0,9): if matrix_board[row][i]==number: check=1 for i in range(0,9): if matrix_board[i][column]==number: check=1 row=row-row%3 column=column-column%3 for i in range(0,3): for j in range(0,3): if matrix_board[row+i][column+j]==number: check=1 if check==1: return False else: return True class calls: number_of_calls=0 c = calls() def sudoku_solver(matrix): c.number_of_calls=c.number_of_calls+1 break_condition=0 for i in range(0,9): for j in range(0,9): if matrix[i][j]==0: break_condition=1 row=i column=j break #print(matrix) #print(break_condition) if break_condition==0: print("Naive Backtracking Algorithm Solution: ") global fuck fuck = matrix return fuck print("Amount of Recursions") print(c.number_of_calls) exit(0) #print("hello") for i in range(0,10): if check_soduku(row,column,i,matrix): matrix[row][column]=i if sudoku_solver(matrix): return True matrix[row][column]=0 return False tn = telnetlib.Telnet("47.108.165.60",port=25894,timeout=40) tn.set_debuglevel(2) print(tn.read_very_eager()) tn.write(b'1\n') tn.write(b'7\n') tn.write(b'r\n') list = tn.read_until(b'Retstart the game? (Y):').decode() tn.write(b'y\n') newlist = list[250:len(list)-24] sudo = [] noooo = [] line = [] line1 = [] lin_b = '' for i in range(len(newlist)): if '0' <= newlist[i] <= '9': lin_b = lin_b + newlist[i] lin_b = lin_b.replace('7320','') lin_b = lin_b.replace('1320','') lin_b = lin_b.replace('732','') for i in lin_b: line.append(int(i)) line1.append(int(i)) if len(line) == 9: sudo.append(line) noooo.append(line1) line = [] line1 = [] print(noooo) sudoku_solver(sudo) move(noooo,fuck,tn)烦人的压缩包
暴力破解
图片提取出压缩包后okk解密即可