https://school.programmers.co.kr/learn/courses/30/lessons/161990
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
def solution(wallpaper):
minxCnt=len(wallpaper)
maxxCnt=0
minyCnt=len(wallpaper[0])
maxyCnt=0
for i,line in enumerate(wallpaper):
for j,box in enumerate(line):
if(box=="#"):
minxCnt=min(minxCnt,i)
maxxCnt=max(maxxCnt,i)
minyCnt=min(minyCnt,j)
maxyCnt=max(maxyCnt,j)
answer = [minxCnt,minyCnt,maxxCnt+1,maxyCnt+1]
return answer
말만 길고 쉬웠던 문제, enumerate 을 잘 활용하자!
'코딩테스트' 카테고리의 다른 글
프로그래머스 Level 1 / 덧칠하기 파이썬 (0) | 2023.03.24 |
---|---|
백준 11059 크리 문자열 파이썬 (0) | 2023.01.24 |
프로그래머스 2차원으로 만들기 파이썬 (0) | 2022.12.24 |
프로그래머스 모스부호(1) 파이썬 (0) | 2022.12.17 |