-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Description
FORTRESS self review 
1. ํด๊ฒฐ ์๋ ๊ณผ์
ํ์ฌ ์ฑ์์ ๊ฐ์ฅ ๋ง์ ์ฑ๋ฒฝ์ ๋์ด์ผํ๋ ๊ฒฝ๋ก๋
ํธ๋ฆฌ์์ ๊ฐ์ฅ ๋ฉ๋ฆฌ ์๋ ๋ ๋
ธ๋๋ฅผ ์ฐพ๋๊ฒ๊ณผ ๋์ผํฉ๋๋ค.
ํ์ฌ ๋
ธ๋๋ฅผ ๋ฃจ๋๋ก ํ๋ ํธ๋ฆฌ์์ ์ต๋ ๋์ด๋ฅผ ๊ตฌํ๋ ์ฌ๊ทํจ์(max_height)์ ๊ตฌํํ๊ณ
is_child๋ก ์ฐ๊ฒฐ๊ด๊ณ๋ฅผ ํ์
ํ๊ณ ์ ํ์ต๋๋ค.
2. ์์ฑํ ์ฝ๋์ ์ค๋ช
def do_enclose(root, child, walls):
R = walls[root]
C = walls[child]
if R[2] > C[2]:
return (R[2] - C[2]) ** 2 > (R[1]-C[1]) ** 2 + (R[0]-C[0]) ** 2def is_child(root, child, walls):
if not do_enclose(root, child, walls):
return False
for i in range(len(walls)):
if i != root and i != child and do_enclose(root, i, walls) and do_enclose(i, child, walls):
return False
return Trueclass Node:
def __init__(self, root, walls):
self.children = []
for i in range(len(walls)):
if is_child(root, i, walls):
self.children.append(i)
def max_height(walls):
longest = 0
# node๋ฅผ root๋ก ํ๋ ํธ๋ฆฌ์ ์ต๋ ๋์ด
# ์ด ํธ๋ฆฌ ๋ด์์ ๋
ธ๋ ๊ฐ ์ต๋ ๊ฑฐ๋ฆฌ๋ฅผ ๊ตฌํ๋ค
def find(root):
node = Node(root, walls)
heights = []
for child in node.childern:
# ๋ฃจํธ ๋
ธ๋ ๋ด์์ ์๋ธ ํธ๋ฆฌ์ ๋์ด ์ ์ฅ
heights.append(find(child))
# ์์๋
ธ๋๊ฐ ์๋ค๋ ๊ฒ์ ์์ ์ด ์ ์ผ ๋, ์ ๋
ธ๋
if not heights:
return 03. ๋งํ ์ ๋ฐ ๊ฐ์ ์ฌํญ
์ต๋ ๋์ด๋ฅผ ๊ตฌํ๋ ๊ณผ์ ์์ ๋งํ์ต๋๋ค.
Reactions are currently unavailable