sudoku1 = "003020600900305001001806400008102900700000008006708200002609500800203009005010300" sudoku2 = "200080300\n060070084\n030500209\n000105408\n\n000000000\n402706000\n301007040\n720040060\n004010003" sudoku3 = "......9.7\r\n...42.18.\r\n...7.5.26\r\n1..9.4...\r\n.5.....4.\r\n...5.7..9\r\n92.1.8...\r\n.34.59...\r\n5.7......" def parse(s): res = [[0 for y in range(9)] for x in range(9)] x=0 y=0 for c in s: if (c>="0" and c<="9") or (c=="."): if c==".": c="0" res[x][y] = int(c) x+=1 if (x==9): x=0; y+=1 return res def ascii(f): hbar1 = ("#==="+"===="*2)*3+"#\n" hbar2 = ("#---"+"+---"*2)*3+"#\n" symbols = [str(i) for i in range(10)] symbols[0] = " " separators = ["|", "|", "#"] res = hbar1 for y in range(9): res += "#" for x in range(9): res += " "+symbols[f[x][y]]+" "+separators[x%3] res+="\n" if y%3==2: res += hbar1 else: res += hbar2 return res print(ascii(parse(sudoku1))) print(ascii(parse(sudoku2))) print(ascii(parse(sudoku3)))