Post

๐ŸฆŠ ๊ฐœ์ธ์ •๋ณด ์ˆ˜์ง‘ ์œ ํšจ๊ธฐ๊ฐ„

1. ๋ฌธ์ œ ๋งํฌ

2023 KAKAO BLIND RECRUITMENT: ๊ฐœ์ธ์ •๋ณด ์ˆ˜์ง‘ ์œ ํšจ๊ธฐ๊ฐ„


2. ์ฝ”๋“œ

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from dateutil.relativedelta import relativedelta
import datetime

def is_day_after_month(now, date, month):
    y1, m1, d1 = map(int, now.split("."))
    y2, m2, d2 = map(int, date.split("."))
    
    now = datetime.date(year = y1, month = m1, day = d1)
    
    date = datetime.date(year = y2, month = m2, day = d2)
    month = relativedelta(months = month)
    
    if date + month <= now:
        return True
    return False
    
def solution(today, terms, privacies):
    TERMS = dict()
    for term in terms:
        alpha, month = term.split()
        TERMS[alpha] = int(month)
    print(TERMS)
    
    answer = []
    for i in range(len(privacies)):
        date, term = privacies[i].split()
        if is_day_after_month(today, date, TERMS[term]):
            answer.append(i + 1)
    return answer


  • ์ •ํ™•์„ฑ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
์ฑ„์ ์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.
์ •ํ™•์„ฑ  ํ…Œ์ŠคํŠธ
ํ…Œ์ŠคํŠธ 1 ใ€‰	ํ†ต๊ณผ (0.09ms, 11.1MB)
ํ…Œ์ŠคํŠธ 2 ใ€‰	ํ†ต๊ณผ (0.16ms, 11MB)
ํ…Œ์ŠคํŠธ 3 ใ€‰	ํ†ต๊ณผ (0.17ms, 11MB)
ํ…Œ์ŠคํŠธ 4 ใ€‰	ํ†ต๊ณผ (0.11ms, 11.2MB)
ํ…Œ์ŠคํŠธ 5 ใ€‰	ํ†ต๊ณผ (0.16ms, 11.2MB)
ํ…Œ์ŠคํŠธ 6 ใ€‰	ํ†ต๊ณผ (0.35ms, 11.1MB)
ํ…Œ์ŠคํŠธ 7 ใ€‰	ํ†ต๊ณผ (0.18ms, 11.1MB)
ํ…Œ์ŠคํŠธ 8 ใ€‰	ํ†ต๊ณผ (0.22ms, 11.1MB)
ํ…Œ์ŠคํŠธ 9 ใ€‰	ํ†ต๊ณผ (0.59ms, 11.1MB)
ํ…Œ์ŠคํŠธ 10 ใ€‰	ํ†ต๊ณผ (0.78ms, 11.1MB)
ํ…Œ์ŠคํŠธ 11 ใ€‰	ํ†ต๊ณผ (0.74ms, 11.1MB)
ํ…Œ์ŠคํŠธ 12 ใ€‰	ํ†ต๊ณผ (1.81ms, 11.2MB)
ํ…Œ์ŠคํŠธ 13 ใ€‰	ํ†ต๊ณผ (1.85ms, 11.1MB)
ํ…Œ์ŠคํŠธ 14 ใ€‰	ํ†ต๊ณผ (1.06ms, 11.1MB)
ํ…Œ์ŠคํŠธ 15 ใ€‰	ํ†ต๊ณผ (0.64ms, 10.9MB)
ํ…Œ์ŠคํŠธ 16 ใ€‰	ํ†ต๊ณผ (1.51ms, 11MB)
ํ…Œ์ŠคํŠธ 17 ใ€‰	ํ†ต๊ณผ (1.20ms, 11.1MB)
ํ…Œ์ŠคํŠธ 18 ใ€‰	ํ†ต๊ณผ (1.19ms, 11.2MB)
ํ…Œ์ŠคํŠธ 19 ใ€‰	ํ†ต๊ณผ (1.15ms, 11.1MB)
ํ…Œ์ŠคํŠธ 20 ใ€‰	ํ†ต๊ณผ (3.14ms, 10.9MB)
์ฑ„์  ๊ฒฐ๊ณผ
์ •ํ™•์„ฑ: 100.0
ํ•ฉ๊ณ„: 100.0 / 100.0


3. ํ•ด์„ค

๊ฐ month ์— ๋Œ€ํ•ด ํ•œ๋‹ฌ์„ ๋”ํ–ˆ์„ ๊ฒฝ์šฐ today ๋ฅผ ์ดˆ๊ณผํ•˜๋ฉด ์ •๋‹ต์œผ๋กœ ์ถœ๋ ฅ

datetime ๊ณผ dateutil ๋ชจ๋“ˆ์„ ์‚ฌ์šฉํ•จ

This post is licensed under CC BY 4.0 by the author.