Notice
Recent Posts
Recent Comments
Link
«   2025/11   »
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
30
Tags
more
Archives
Today
Total
관리 메뉴

하루에 하나씩 공부하기

프로그래머스 LV1 - 유연근무제 본문

파이썬

프로그래머스 LV1 - 유연근무제

dltaexox 2025. 6. 27. 19:46

- 문제

 

코딩테스트 연습 - 유연근무제 | 프로그래머스 스쿨

 

프로그래머스

SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr

 

- 고민한 점

9시58분에 10분을 더하면 968이 아니라 1008이 되어야 함

토,일 주말 인덱스를 어떻게 접근해야 할까

 

- 코드

def solution(schedules, timelogs, startday):
    answer = 0
    new_schedules=[]
    # 시간 계산 진행
    for schedule in schedules:
        hour = schedule // 100
        minute = schedule % 100
        # 안전시간 10분 추가
        minute = (minute + 10) % 60
        # 60분 초과시 시간 증가
        hour += (schedule % 100 + 10) // 60 
        new_schedules.append(hour * 100 + minute)
    
    for i in range(len(timelogs)):
        count=0
        for day in range(7):
            today= (startday+day) % 7
            # today가 0, 6일 경우 토요일, 일요일
            if today in {0, 6} :
                continue
            if timelogs[i][day] <= new_schedules[i]: 
                count+=1
        if count == 5:
        	answer+=1
    return answer

'파이썬' 카테고리의 다른 글

코딩테스트 입문 - 옹알이(1)  (0) 2025.06.21
K번째수-LV1  (0) 2025.03.09
베스트앨범-LV3  (1) 2025.03.09
의상-LV2  (0) 2025.02.28
전화번호 목록-LV2  (0) 2025.02.27