05-18 01:37
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- descriptive statistics
- systemd
- Polymolphism
- literal
- Class
- Binary Search
- selenium
- OOP
- 자바
- 리눅스 마스터 1급
- BFS
- 리눅스
- Reference Type
- dbms
- External Scheme
- Mac
- Unity
- Java
- 셀레니움
- python
- preprocessing
- Operator
- 백준
- X윈도우
- Physical Scheme
- Entity
- Inheritance
- spring
- X.org
- Entity Set
Archives
- Today
- Total
Byeol Lo
백준 많은 직사각형에 대해 외곽만 그리기 본문
직사각형이 다음과 같이 주어진다고 하자. (x1, y1, x2, y2) 좌표계는 1부터 50까지 있다고 치면,
많은 직사각형들에 대해 외곽을 다음 로직을 통해 list로 구현 할 수 있다.
def draw(rectangles) :
map = [[9]*50 for _ in range(50)]
for rect in rectangles :
for x in range(rect[0], rect[2]+1) :
for y in range(rect[1], rect[3]+1) :
if rect[0] < x < rect[2] and rect[1] < y < rect[3] : map[y][x] = 0
elif map[y][x] : map[y][x] = 1
for i in map : print(*i)
if __name__ == "__main__" :
draw([[1,1,7,4],[3,2,5,5],[4,3,6,9],[2,6,8,8]])
직사각형들에 대해 구분을 하기 위해 좌표들을 전부 두배를 해주는 것도 명심하자
'Programming Language > Python' 카테고리의 다른 글
미로찾기 - bfs (0) | 2022.09.02 |
---|---|
미로찾기 - dfs (0) | 2022.09.02 |
Python functools 함수들 (0) | 2022.07.26 |
operator 모듈의 itemgetter, attrgetter 사용하기 (0) | 2022.06.16 |
Numpy 라이브러리 사용 (0) | 2022.06.15 |
Comments