diff --git a/.DS_Store b/.DS_Store index e075092..7ead73e 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/029_snail.py b/029_snail.py index 076e490..b9889df 100644 --- a/029_snail.py +++ b/029_snail.py @@ -12,27 +12,27 @@ def snail(array): print(snail(array)) -def snail(array): - dizi= [] - n = len(array) - while n>0: - if array==[[]]: break - for i in range(len(array)-1): - if i == 0: - dizi.extend(array[i]) - array.pop(i) - n -= 1 - dizi.append(array[i][-1]) - else: - dizi.append(array[i][-1]) - for i in range(len(array)-1,-1,-1): - dizi.append(array[-1][i]) - array.pop(-1) - n -= 1 - for i in range(len(array)-1,-1,-1): - dizi.append(array[i][0]) - array2=[] - for i in array: - array2.append(i[1:-1]) - array = array2 - return dizi \ No newline at end of file +# def snail(array): +# dizi= [] +# n = len(array) +# while n>0: +# if array==[[]]: break +# for i in range(len(array)-1): +# if i == 0: +# dizi.extend(array[i]) +# array.pop(i) +# n -= 1 +# dizi.append(array[i][-1]) +# else: +# dizi.append(array[i][-1]) +# for i in range(len(array)-1,-1,-1): +# dizi.append(array[-1][i]) +# array.pop(-1) +# n -= 1 +# for i in range(len(array)-1,-1,-1): +# dizi.append(array[i][0]) +# array2=[] +# for i in array: +# array2.append(i[1:-1]) +# array = array2 +# return dizi \ No newline at end of file diff --git a/030_sudoku.py b/030_sudoku.py index eba4aaa..f4eafd4 100644 --- a/030_sudoku.py +++ b/030_sudoku.py @@ -15,11 +15,10 @@ def valid_solution(board): dik = [list(map(lambda x:x[a],board)) for a in range(len(board))] - # dik = [] # for a in range(len(board)) # dik.extend(list(map(lambda x:x[a],board))) - + print(dik) k_dokuz=[list(map(lambda x:x[i:i+3],board[k:k+3])) for i in range(0,9,3)\ for k in range(0,9,3)] @@ -27,17 +26,17 @@ def valid_solution(board): # for k in range(0,9,3): # for i in range(0,9,3): # k_dokuz.extend(list(map(lambda x:x[i:i+3],board[k:k+3]))) - + print(k_dokuz) k_dokuz= [i[0]+i[1]+i[2] for i in k_dokuz] # y_k_dokuz = [] # for i in k_dokuz: # y_k_dokuz += [i[0]+i[1]+i[2]] - for i in board,dik,k_dokuz: - for k in i: - if set(k)!={1,2,3,4,5,6,7,8,9}: - return False - break + for i in board,dik,k_dokuz: + for k in i: + if set(k)!={1,2,3,4,5,6,7,8,9}: return False; break return True -# print(valid_solution(board)) \ No newline at end of file +# print(valid_solution(board)) + +print(valid_solution(board)) \ No newline at end of file diff --git a/027_max_sum_sub.py b/033_max_sum_sub.py similarity index 100% rename from 027_max_sum_sub.py rename to 033_max_sum_sub.py