Post

Programmers. Wallpaper_set

바탕화면 정리

  • practice problem
  • 정답률: 41%
  • 2023.06.29
  • 13:00 ~ 13:25 (25 min)
  • 후기: min, max와 조건문을 활용하는 문제

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def solution(wallpaper):
    answer = []
    min_x = 9999
    min_y = 9999
    max_x = 0
    max_y = 0
    
    for i, row in enumerate(wallpaper):
        for j, char in enumerate(str(row)):
            if char == "#":
                if min_x > i:
                    min_x = i
                if min_y > j:
                    min_y = j
                if max_x <= i:
                    max_x = i + 1
                if max_y <= j:
                    max_y = j + 1
    answer.append(min_x)
    answer.append(min_y)
    answer.append(max_x)
    answer.append(max_y)
    return answer
This post is licensed under CC BY 4.0 by the author.