강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

phillnfeel님의 프로필 이미지
phillnfeel

작성한 질문수

파이썬 알고리즘 문제풀이 입문(코딩테스트 대비)

11. 격자판 회문수

살짝 다르게 풀었는데 어떤지 봐주세요! 테스트케이스는 다 통과했습니다

작성

·

186

0

import sys
sys.stdin=open("input.txt", "rt")

a=[list(map(int, input().split())) for _ in range(7)]


cnt =0

for i in range(7): #행, 열
    start = 0
    for _ in range(3):
        
        if a[i][start]==a[i][start+4] and a[i][start+1]==a[i][start+3]:
            cnt+=1
        if a[start][i]==a[start+4][i] and a[start+1][i]==a[start+3][i]:
            cnt+=1
            
        start+=1
        if start ==3:
            break

print(cnt)

답변 1

0

김태원님의 프로필 이미지
김태원
지식공유자

안녕하세요^^

네. 잘하신 코드입니다. 

phillnfeel님의 프로필 이미지
phillnfeel

작성한 질문수

질문하기