Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12-kjs254 #50

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kjs254/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
| 9μ°¨μ‹œ | 2024.03.10 | κ΅¬ν˜„ | [λ‰΄μŠ€ ν΄λŸ¬μŠ€ν„°λ§](https://school.programmers.co.kr/learn/courses/30/lessons/17677) | [#33](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/33) |
| 10μ°¨μ‹œ | 2024.04.02 | ν•΄μ‹œ | [μ „ν™”λ²ˆν˜Έ λͺ©λ‘](https://school.programmers.co.kr/learn/courses/30/lessons/42577) | [#46](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/46) |
| 11μ°¨μ‹œ | 2024.04.05 | DFS | [νƒ€κ²Ÿ λ„˜λ²„](https://school.programmers.co.kr/learn/courses/30/lessons/43165) | [#47](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/47) |
| 12μ°¨μ‹œ | 2024.04.11 | DFS | [μ•ˆμ „μ§€λŒ€](https://school.programmers.co.kr/learn/courses/30/lessons/120866) | [#50](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/50) |
17 changes: 17 additions & 0 deletions kjs254/κ΅¬ν˜„/μ•ˆμ „μ§€λŒ€.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def solution(board):
n = len(board)
for i in range(n):
board[i].insert(0,-1)
board[i].append(-1)
board.insert(0,[-1]*(n+2))
board.append([-1]*(n+2))
Comment on lines +3 to +7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n = len(board)
board = [[-1, *line, -1] for line in board]  # 각 ν–‰λ§ˆλ‹€ 맨 μ•ž, 맨 뒀에 -1 λΆ™μž„
board = [[-1] * (n + 2), *board, [-1] * (n + 2)]  # 0ν–‰ μ•ž, λ§ˆμ§€λ§‰ ν–‰ 뒀에 [-1, ...] 1차원 리슀트 λΆ™μž„

-1 νŒ¨λ”©μ€ μš”λ ‡κ²Œ 2μ€„λ‘œ ν•  수 μžˆλ‹΅λ‹ˆλ‹€ :)


for i in range(n+2):
for j in range(n+2):

if board[i][j]==1:
for dx in (-1,0,1):
for dy in (-1,0,1):
board[i+dy][j+dx] = board[i+dy][j+dx]*2 -1

return sum(board, []).count(0)