'programmers' ์นดํ
๊ณ ๋ฆฌ์ ๊ธ ๋ชฉ๋ก (25 Page)
[python] ํํ
๋ฌธ์ ์ค๋ช
์ ๋ค ๊ฐ์ ์ขํ๋ฅผ ๋ด์ ์ด์ฐจ์ ๋ฐฐ์ด dots๊ฐ ๋ค์๊ณผ ๊ฐ์ด ๋งค๊ฐ๋ณ์๋ก ์ฃผ์ด์ง๋๋ค.[[x1, y1], [x2, y2], [x3, y3], [x4, y4]]์ฃผ์ด์ง ๋ค ๊ฐ์ ์ ์ ๋ ๊ฐ์ฉ ์ด์์ ๋, ๋ ์ง์ ์ด ํํ์ด ๋๋ ๊ฒฝ์ฐ๊ฐ ์์ผ๋ฉด 1์ ์์ผ๋ฉด 0์ return ํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด๋ณด์ธ์. ์
์ถ๋ ฅ ์dotsresult[[1, 4], [9, 2], [3, 8], [11, 6]]1[[3, 5], [4, 1], [2, 4], [5, 10]]0 ์ ์ถ ๋ด์ญdef solution(dots): x = [dots[0][0], dots[1][0], dots[2][0], dots[3][0]] y = [dots[0][1], dots[1][1], dots[2][1], dots[3]..
2025. 1. 16.
[python] ์ธ๊ณ์ด ์ฌ์
๋ฌธ์ ์ค๋ช
PROGRAMMERS-962 ํ์ฑ์ ๋ถ์์ฐฉํ ์ฐ์ฃผ๋นํ์ฌ ๋จธ์ฑ์ด๋ ์ธ๊ณํ์ฑ์ ์ธ์ด๋ฅผ ๊ณต๋ถํ๋ ค๊ณ ํฉ๋๋ค. ์ํ๋ฒณ์ด ๋ด๊ธด ๋ฐฐ์ด spell๊ณผ ์ธ๊ณ์ด ์ฌ์ dic์ด ๋งค๊ฐ๋ณ์๋ก ์ฃผ์ด์ง๋๋ค. spell์ ๋ด๊ธด ์ํ๋ฒณ์ ํ๋ฒ์ฉ๋ง ๋ชจ๋ ์ฌ์ฉํ ๋จ์ด๊ฐ dic์ ์กด์ฌํ๋ค๋ฉด 1, ์กด์ฌํ์ง ์๋๋ค๋ฉด 2๋ฅผ returnํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์. ์
์ถ๋ ฅ ์spelldicresult["p", "o", "s"]["sod", "eocd", "qixm", "adio", "soo"]2["z", "d", "x"]["def", "dww", "dzx", "loveaw"]1["s", "o", "m", "d"]["moos", "dzx", "smm", "sunmmo", "som"]2 ์ ์ถ ๋ด์ญdef solution(sp..
2025. 1. 15.
[python] ์ผ๊ฐํ์ ์์ฑ์กฐ๊ฑด (2)
๋ฌธ์ ์ค๋ช
์ ๋ถ ์ธ ๊ฐ๋ก ์ผ๊ฐํ์ ๋ง๋ค๊ธฐ ์ํด์๋ ๋ค์๊ณผ ๊ฐ์ ์กฐ๊ฑด์ ๋ง์กฑํด์ผ ํฉ๋๋ค.๊ฐ์ฅ ๊ธด ๋ณ์ ๊ธธ์ด๋ ๋ค๋ฅธ ๋ ๋ณ์ ๊ธธ์ด์ ํฉ๋ณด๋ค ์์์ผ ํฉ๋๋ค.์ผ๊ฐํ์ ๋ ๋ณ์ ๊ธธ์ด๊ฐ ๋ด๊ธด ๋ฐฐ์ด sides์ด ๋งค๊ฐ๋ณ์๋ก ์ฃผ์ด์ง๋๋ค. ๋๋จธ์ง ํ ๋ณ์ด ๋ ์ ์๋ ์ ์์ ๊ฐ์๋ฅผ returnํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์. ์
์ถ๋ ฅ ์sidesresult[1, 2]1[3, 6]5[11, 7]13 ์ ์ถ ๋ด์ญdef solution(sides): a, b = max(sides), min(sides) return len(range(a-b+1, a+1)) + len(range(a+1, a+b)) ๊ฐ์ฅ ๊ธด ๋ณ์ด a์ผ ๋,a-b ๊ฐ์ฅ ๊ธด ๋ณ์ด c์ผ ๋,a ํ๋ก๊ทธ๋๋จธ์ค ์ฝ๋ฉํ
์คํธ ์
๋ฌธ Day21 ๋ฌธ์์ด, ..
2025. 1. 15.