๐น ์๋ ๋ก๊ทธ ์๊ณ
1. ๋ฌธ์ ๋งํฌ
PCCP 3๋ฒ: ์๋ ๋ก๊ทธ ์๊ณ
2. ์ฝ๋
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# ๋ถ์นจ๊ณผ ์ด์นจ์ด ๋ง๋๋ ๋ชจ๋ ๊ฒฝ์ฐ(๋ถ๋จ์)
minute_hand = [(6 * i / (6 - 0.1)) for i in range(1440)]
# ์์นจ๊ณผ ์ด์นจ์ด ๋ง๋๋ ๋ชจ๋ ๊ฒฝ์ฐ(๋ถ๋จ์)
hour_hand = [(6 * i / (6 - 30/3600)) for i in range(1440)]
def solution(h1, m1, s1, h2, m2, s2):
start = h1 * 60 + m1 + s1 / 60
end = h2 * 60 + m2 + s2 / 60
print(start, end)
time_to_meet = []
for i in range(1440):
if start <= hour_hand[i] <= end and hour_hand[i] not in time_to_meet:
time_to_meet.append(hour_hand[i])
if start <= minute_hand[i] <= end and minute_hand[i] not in time_to_meet:
time_to_meet.append(minute_hand[i])
return len(time_to_meet)
ํ ์คํธ ๊ฒฐ๊ณผ
ํ ์คํธ 1 ใ ํต๊ณผ (3.64ms, 10.4MB) ํ ์คํธ 2 ใ ํต๊ณผ (10.06ms, 10.3MB) ํ ์คํธ 3 ใ ํต๊ณผ (0.92ms, 10.4MB) ํ ์คํธ 4 ใ ํต๊ณผ (11.92ms, 10.5MB) ํ ์คํธ 5 ใ ํต๊ณผ (0.21ms, 10.3MB) ํ ์คํธ 6 ใ ํต๊ณผ (1.30ms, 10.4MB) ํ ์คํธ 7 ใ ํต๊ณผ (18.48ms, 10.2MB) ํ ์คํธ 8 ใ ํต๊ณผ (9.19ms, 10.3MB) ํ ์คํธ 9 ใ ํต๊ณผ (15.31ms, 10.1MB) ํ ์คํธ 10 ใ ํต๊ณผ (17.43ms, 10.2MB) ํ ์คํธ 11 ใ ํต๊ณผ (4.59ms, 10.2MB) ํ ์คํธ 12 ใ ํต๊ณผ (0.58ms, 10.3MB) ํ ์คํธ 13 ใ ํต๊ณผ (32.16ms, 10.3MB) ํ ์คํธ 14 ใ ํต๊ณผ (11.93ms, 10.3MB) ํ ์คํธ 15 ใ ํต๊ณผ (0.39ms, 10.3MB) ํ ์คํธ 16 ใ ํต๊ณผ (4.08ms, 10.3MB) ํ ์คํธ 17 ใ ํต๊ณผ (8.91ms, 10.3MB) ํ ์คํธ 18 ใ ํต๊ณผ (0.43ms, 10.2MB) ํ ์คํธ 19 ใ ํต๊ณผ (67.18ms, 10.3MB) ํ ์คํธ 20 ใ ํต๊ณผ (52.37ms, 10.2MB)
3. ํด์ค
๋ถ์นจ๊ณผ ์ด์นจ์ด 24์๊ฐ ๋ด์ ๋ง๋๋ ๋ชจ๋ ๊ฒฝ์ฐ๋ฅผ minute_hand์, ์์นจ๊ณผ ์ด์นจ์ด 24์๊ฐ ๋ด์ ๋ง๋๋ ๋ชจ๋ ๊ฒฝ์ฐ๋ฅผ hour_hand์ ์ด๊ธฐํํ๋ค. ์ด๋ ๋ถ ๋จ์๋ก (1440๋ถ) ๊ณ์ฐํ๋ค.
์ฃผ์ด์ง ์๊ฐ์ ๋ถ ๋จ์๋ก ๋ณ๊ฒฝํ๊ณ ์์ ์๊ฐ๊ณผ ๋๋๋ ์๊ฐ ์ฌ์ด์ ๋ค์ด์ค๋ ๋ง๋๋ ๊ฒฝ์ฐ๋ฅผ ๋ชจ๋ ์ธ์ค๋ค. ์ด
๋ ๋ถ์นจ, ์์นจ, ์ด์นจ์ด ํ ๋ฒ์ ๋ง๋๋ ๊ฒฝ์ฐ๊ฐ ์์ผ๋ฏ๋ก, ์์นจ-์ด์นจ ๋ง๋๋ ์๊ฐ, ๋ถ์นจ-์ด์นจ ๋ง๋๋ ์๊ฐ์ time_to_meet ๋ฆฌ์คํธ์ ๋ฃ์ด์ฃผ๊ณ ํด๋น ๋ฆฌ์คํธ์ ์ด๋ฏธ ๊ฐ์ด ์กด์ฌํ๋ ๊ฒฝ์ฐ์๋ ๋ฌด์ํ๋ค.
์ต์ข ์ ์ผ๋ก time_to_meet ๋ฆฌ์คํธ์ ๊ธธ์ด๋ฅผ ๋ฆฌํดํ๋ค.
This post is licensed under CC BY 4.0 by the author.