공부-코딩테스트/코테풀이 - 자바, 파이썬
1220. [S/W 문제해결 기본] 5일차 - Magnetic (코딩테스트, SW Expert Academy)
령과
2022. 5. 7. 12:55
문제
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14hwZqABsCFAYD
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
나의 코드 : 11분 30초
T = 10
for test_case in range(1, T + 1):
N = int(input())
table = []
answer = 0
for i in range(N):
table.append(list(map(int, input().split())))
for i in zip(*table):
target = [j for j in i if j != 0]
for j in range(len(target)-1):
if target[j:j+2] == [1,2]:
answer += 1
print("#"+str(test_case),answer)
D3라서 풀어보았으나 그냥 단순한 아이디어로 풀린 문제다. zip(*table)을 통해서 세로열을 불러와서
12(순서주의)의 갯수를 count하면 끝인 문제
문제를 풀어보며 프로그래머스는 구현이 까다롭고 SWEA는 생각을 조금 해보면 편한 방법이 존재하는 문제가 많은 듯함