Skip to content

Commit

Permalink
Merge pull request #154 from AlgoLeadMe/38-pknujsp
Browse files Browse the repository at this point in the history
38-pknujsp
  • Loading branch information
MunbinLee authored May 3, 2024
2 parents 3c10fb8 + 37805ad commit 66ea60f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ์ž๋ฌผ์‡ ์˜ ์ค‘๊ฐ„ ๋ถ€๋ถ„์ด ๋ชจ๋‘ 1์ธ์ง€ ํ™•์ธ
def is_valid(new_lock):
length = len(new_lock) // 3

for r in range(length, length * 2):
for c in range(length, length * 2):
if new_lock[r][c] != 1:
return False

return True

def solution(key, lock):
n = len(lock)
k = len(key)
new_lock = [[0] * (n * 3) for _ in range(n * 3)]

for r in range(n):
for c in range(n):
new_lock[r + n][c + n] = lock[r][c]

for _ in range(4):
rev_key = key[::-1]
key = []
for c in range(k):
row = []
for r in range(k):
row.append(rev_key[r][c])
key.append(row)

"""
์—ด์‡ ๋ฅผ ๋Œ๋ฆฌ๋Š” ๋กœ์ง์€ ํ•œ ์ค„๋กœ๋„ ๊ตฌํ˜„๊ฐ€๋Šฅ ํ•ฉ๋‹ˆ๋‹ค
key = [row for row in zip(*reversed(key))]
"""

for r in range(n * 2):
for c in range(n * 2):
# ์ž๋ฌผ์‡ ์— ์—ด์‡ ๋ฅผ ๋ผ์šด๋‹ค
for i in range(k):
for j in range(k):
new_lock[r + i][c + j] += key[i][j]

# ์ž๋ฌผ์‡ ์— ์—ด์‡ ๊ฐ€ ๋”ฑ ๋“ค์–ด๊ฐ”๋Š”์ง€ ํ™•์ธ
if is_valid(new_lock):
return True

# ์ž๋ฌผ์‡ ์—์„œ ์—ด์‡ ๋ฅผ ๋นผ์„œ ๋ณต๊ตฌ์‹œํ‚จ๋‹ค
for i in range(k):
for j in range(k):
new_lock[r + i][c + j] -= key[i][j]
return False
3 changes: 2 additions & 1 deletion pknujsp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@
| 34์ฐจ์‹œ | 2024.02.12 | BFS | [์ด๋ถ„ ๊ทธ๋ž˜ํ”„](https://www.acmicpc.net/problem/1707) | [#135](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/135) |
| 35์ฐจ์‹œ | 2024.02.18 | ๊ทธ๋ฆฌ๋”” | [์„ ๋ฌผํ• ์ธ](https://www.acmicpc.net/problem/25947) | [#137](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/137) |
| 36์ฐจ์‹œ | 2024.02.21 | ์ด์ง„ํƒ์ƒ‰ | [ํœด๊ฒŒ์†Œ ์„ธ์šฐ๊ธฐ](https://www.acmicpc.net/problem/1477) | [#143](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/143) |
| 37์ฐจ์‹œ | 2024.03.04 | ๊ตฌํ˜„ | [n+1 ์นด๋“œ๊ฒŒ์ž„](https://school.programmers.co.kr/learn/courses/30/lessons/258707) | [#149](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/149) |
| 37์ฐจ์‹œ | 2024.03.04 | ๊ตฌํ˜„ | [n+1 ์นด๋“œ๊ฒŒ์ž„](https://school.programmers.co.kr/learn/courses/30/lessons/258707) | [#149](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/149) |
| 38์ฐจ์‹œ | 2024.03.08 | BRUTE_FORCE | [์ž๋ฌผ์‡ ์™€ ์—ด์‡ ](https://school.programmers.co.kr/learn/courses/30/lessons/60059) | [#154](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/154) |

0 comments on commit 66ea60f

Please sign in to comment.