알고리즘: 지도 자동 구축
2021. 9. 28. 21:58ㆍAlgorithm
- 목차
반응형
N = 2
size = 2**N
grid = [[0]*size for _ in range(size)]
rows = len(grid)
cols = len(grid[0])
score = 0
for y in range(rows):
for x in range(cols):
if ((y == 0 and x == 0) or
(y == rows - 1 and x == cols - 1) or
(y == rows - 1 and x == 0) or
(y == 0 and x == cols - 1)):
score += 2.25
elif (y == 0 or x == 0 or x == cols - 1 or y == rows - 1):
score += 1.5
else:
score += 1
print(int(score))
반응형