[SWEA] 스도쿠 검증

Date:

[SWEA] 스도쿠 검증

Problem URL : 스도쿠 검증

TC = int(input())

for tc in range(1, TC + 1):
    arr = []
    for i in range(9):
        arr.append(list(map(int, input().split())))
    sdoku = True

    for i in range(9):
        chk1 = [False] * 10
        chk2 = [False] * 10
        chk3 = [False] * 10
        for j in range(9):
            if chk1[arr[i][j]] or chk2[arr[j][i]] or chk3[arr[(i % 3) * 3 + (j % 3)][(i // 3) * 3 + j // 3]]:
                sdoku = False
                break
            else:
                chk1[arr[i][j]] = True
                chk2[arr[j][i]] = True
                chk3[arr[(i % 3) * 3 + (j % 3)][(i // 3) * 3 + j // 3]] = True

            if not sdoku:
                break


    print("#{} {}".format(tc, int(sdoku)))

댓글