-
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
14-H0ngJu #183
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.
for chickens in combinations(chicken_house, M): | ||
total = 0 | ||
for r in range(N): | ||
for c in range(N): | ||
if house[r][c] == 1: | ||
tmp = 9999 | ||
for chicken in chickens: | ||
tmp = min(tmp, abs(r - chicken[0]) + abs(c - chicken[1])) | ||
total += tmp | ||
|
||
result = min(result, total) |
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.
μ μ§μ§ combinations μλ μ¬λΌκ°μ§κ³ λ°±νΈλνΉμΌλ‘ ꡬννκ³ μμλλ°..
μκ°μ΄κ³Όλμ νλ±μ§λμ PRλ΄€λλ° μ§μ§ ν무νλ€μ.................
μ§μ§ κ° λ€μ£½μλ°........... γ γ γ γ γ γ γ γ γ γ γ γ γ γ γ γ γ γ γ γ
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.
μ μ΄λ combinations μκ²λκΈ° μ κΉμ§ λ§μ μ½μ§μ΄ μμλ€μ£ .. γ ..γ .γ ..
π λ¬Έμ λ§ν¬
μΉν¨ κ²μ
βοΈ μμλ μκ°
2H
β¨ μλ μ½λ
λ°±νΈλνΉμ΄ κ°λ μ μΌλ‘ λμ§λ μκ² λλ° λ¬Έμ μ μ©μ΄ νλ κ² κ°μμ μ λ¬Έμ λ₯Ό 골λμ΅λλ€ νν
λ¬Έμ μμ½
λ¬Έμ μμ μ μλ μΉν¨ μ§ κ°μλ₯Ό Mκ°λ§ μ΄λ €λμμ λ,
μ 체 μΉν¨ κ±°λ¦¬κ° κ°μ₯ μμ Mκ°μ μ‘°ν©μ ꡬνμ¬ μΉν¨ 거리μ ν©μ λ°ννμ@!
μ΄ λ¬Έμ λ₯Ό νλ©΄μ κ°μ₯ μ²μ νμ΄μΌνλ λ¬Έμ λ
μ΄λ»κ² κ°λ₯ν Mκ°μ μΉν¨ μ§ μ‘°ν©μ μ°Ύμ κ²μΈκ°? μ λλ€.
μ²μμλ Mκ°κ° λ λκΉμ§ 1κ°μ© μ€μ¬λκ°λ©΄μ μ΅μ μΉν¨ 거리λ₯Ό μ°ΎμκΉ? νλλ°..
λκ° λ°°λ³΄λ€ λ°°κΌ½μ΄ μ»€μ§λ λλμ΄λΌ λΉ λ₯΄κ² pass νμ΅λλ€.
κ·Όλ° μ‘°ν©μ λν΄μ μ°Ύμ보λκΉ νμ΄μ¬μμ μ 곡νλ itertoolsκ° μκΈΈλ importν΄μ μ¬μ©νμ΅λλ€
*
combinations(list, N)
μ νκ²λλ©΄ λ°ν κ°μ tupleμ΄ λ©λλ€.κ·Έλ κ² μΉν¨ μ§μ μ μ₯ν΄λ listμ λνμ¬ combinationsλ₯Ό νλ©΄ μμ½κ² λͺ¨λ μ‘°ν©μ κ²½μ°μ μλ₯Ό ꡬν μ μμ΅λλ€.
μ΄νμλ λͺ¨λ μ§λ€μ λλ©°, λͺ¨λ μΉν¨ μ§μ λν μΉν¨ 거리λ₯Ό ꡬν©λλ€.
μ λ μ¬κΈ°μ κ΅³μ΄ λͺ¨λ μΉν¨μ§μ λν 거리λ₯Ό ꡬν νμκ° μλ? μ΄λ μκ° νμΈνμ§ μμλ λλ μΉν¨μ§μ΄ μμ κ² κ°μλ°.. λΌκ³ μκ°ν΄μ λΊλΊ λλ¬κ°μ§λ§,,,
κ²°λ‘ λΆν° λ§νλ©΄ κ·Έλ₯ ν μ§μ λνμ¬ λͺ¨λ μΉν¨ μ§μ λν μΉν¨ 거리λ₯Ό ꡬνκ³ , minμ λ°ννλ κ²μ΄ κ°μ₯ κ°λ¨νμ΅λλ€.
κ·Έλ κ² κ° μ‘°ν©μ λν μΉν¨ 거리 ν©μ ꡬνκ³ , minμ λ°νν΄μ£Όλ©΄ λ¬Έμ λ₯Ό ν μ μμ΅λλ€!
λ‘μ§ μ§λλ° λͺλ² μ½μ§νκ³ tmp μ΄κΈ°νλ₯Ό μλ±ν κ³³μ ν΄μ μκ°μ λ§μ΄ μΌλ€μ νν π π
λΆλͺ μ΄μ λ μͺΌλ§€ μ΄λ €μ λλ° μ€λ 보λκΉ κ·Έμ λλ μλ κ² κ°κΈ°λ? νλ€μ?
π μλ‘κ² μκ²λ λ΄μ©