-
Notifications
You must be signed in to change notification settings - Fork 2
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
38-pknujsp #154
38-pknujsp #154
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3λ°°λ₯Ό λ ν€μμ μ κ·Όνλ€λ 건 μκ°λ λͺ»νλλ° νμ€ν ν€μ°λκΉ λ°°μ΄μμ λ²μ΄λ κ²½μ°μ μ²λ¦¬κ° μμνλ€μ.. λ²μ΄λ κ²½μ°, λ°°μ΄μ μΆκ°λ‘ νμ₯ν νμ μκ³ , μμ§μΌ λλ§λ€ μλ¬Όμ +μ΄μ μ κ°μ΄ λͺ¨λ 1μ΄λ©΄ λλκΉμ
λ¬Έμ νΈλλΌ μκ³ λ§μΌμ ¨μ΅λλ€ π₯π₯
|
||
""" | ||
μ΄μ λ₯Ό λ리λ λ‘μ§μ ν μ€λ‘λ ꡬνκ°λ₯ ν©λλ€ | ||
key = [row for row in zip(*reversed(key))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μλλ무 λ¬Έμ λ³΄κ³ zipμ΄ listλΌλ¦¬ indexλ₯Ό λ¬Άμ΄μ tupleλ‘ λ°ννλ ν¨μꡬλ νλλ° *reversed(key)λ‘ κ° index μμμ μ κ·Όν΄μ tupleλ‘ λ¬Άμ΄μ£Όλ©΄ νμ μ΄ λλκ΅°μ .... μμ©μ΄ μ΄λ κ² λλ€μ
μ½λκ° μ§μ§ μλ¦μ΄ λλ€μ π«’π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def make_new_lock(lock):
new_lock = []
for _ in range(len(lock)):
new_lock.append([2 for _ in range(len(lock[0])*3)])
for row_lock in lock:
temp = []
temp.extend([2 for _ in range(len(row_lock))])
temp.extend(row_lock)
temp.extend([2 for _ in range(len(row_lock))])
new_lock.append(temp)
for _ in range(len(lock)):
new_lock.append([2 for _ in range(len(lock[0])*3)])
return new_lock
def rotate_key(key):
rotated_key = []
for col in range(len(key[0])):
temp = []
for row in range(len(key)):
temp.append(key[len(key)-row-1][col])
rotated_key.append(temp)
return rotated_key
def solution(key, lock):
new_lock = make_new_lock(lock)
hole_count = 0
for row in range(len(new_lock)):
for col in range(len(new_lock)):
if new_lock[row][col] == 0:
hole_count += 1
for _ in range(4):
for row in range(len(lock)-len(key), len(lock)*2+1):
for col in range(len(lock)-len(key), len(lock)*2+1):
temp = 0
for inner_row in range(row, row+len(key)):
for inner_col in range(col, col+len(key)):
if key[inner_row-row][inner_col-col] == 1 and new_lock[inner_row][inner_col] == 0:
temp += 1
elif key[inner_row-row][inner_col-col] == 1 and new_lock[inner_row][inner_col] == 1:
temp += int(1e9)
if hole_count == temp: return True
key = rotate_key(key)
return False
μ€λ§μ΄κ°μ¬...
μνμ΄λ©΄ μ‘°κΈλ§ λ λ Έλ ₯νλ©΄ ν μ μμλλ°...
μν λ¬Έμ μ λ¬Έμ μ : κ³Όμ° μ΄ νμ΄κ° λ§λ κ±ΈκΉ?
λΌκ³ μκ°νλ©° μλλ μν΄λ΄
λ°μ±νκ³ κ°λλ€. (__)
π λ¬Έμ λ§ν¬
μλ¬Όμ μ μ΄μ
βοΈ μμλ μκ°
2μκ°, λμ ν μ λ μ¬λΌμ νμ΄λ³΄κ³ 곡λΆ
β¨ μλ μ½λ
NxN
ν¬κΈ°μ μλ¬Όμ μMxM
ν¬κΈ°μ μ΄μ κ° μκ³ , μ΄μ λ₯Ό νμ μν€κ±°λ νμΉΈ μ© μ΄λμμΌλ³΄λ©΄μ μλ¬Όμ μ μ΄μ κ° λΌμμ§λμ§ νμΈνλ λ¬Έμ μλ¬Όμ μ μ΄μ μ μ΅λν¬κΈ°κ°
20x20
μ΄νμ΄λ―λ‘, μμ νμμΌλ‘ ν μ μλ€.1. μλ¬Όμ μ ν¬κΈ°λ₯Ό 3λ°° ν€μ΄λ€
1ν 1μ΄
λΆν°N * 2ν N * 2μ΄
κΉμ§ μ΄μ λ₯Ό μ΄λμμΌλ³΄λ©΄μ μμ νμμ μννλ€.2. λ€ λ² λ°λ³΅ : νλ² νμ νκ³ μ΄μ κ° λΌμμ§λμ§ λͺ¨λ κ²½μ° νμ
1
μ΄λΌλ©΄ λΌμμ§ κ²μ΄λ€True
λ₯Ό λ°ννμ¬ μ’ λ£νλ€μ΄μ νμ λ°©λ²
C
μ΄μ λͺ¨λ μμλ₯Ό κ·Έλλ‘C
νμΌλ‘ λ§λ€λ©΄ λλ€.zip
ν¨μλ₯Ό μ¬μ©νλ©΄ ν μ€λ‘ ꡬνν μ μμμ μκ²λμλ€3. μ΄λ ν κ²½μ°μλ μ μ΄λ¦¬λ©΄
False
λ₯Ό λ°ννλ€π μλ‘κ² μκ²λ λ΄μ©