def kangaroo(x1, v1, x2, v2):
    # Write your code here
    
    # x1 < x2이므로 속도가 같거나 크면 따라잡을 수 없음
    if v1 <= v2:
        return 'NO'
    else:
    	# v1 > v2여서 따라잡을 수 있는 경우
        # 거리 차를 속도 차가 잡을 수 있고, 같은 위치에 있을 수 있어야함
        r = (x2 - x1) % (v2 - v1)
        if r == 0:
            return 'YES'
        else:
            return 'NO'
def countApplesAndOranges(s, t, a, b, apples, oranges):
    # Write your code here
    print(sum([1 if ((apple + a) >= s and (apple + a) <= t) else 0 for apple in apples]))
    print(sum([1 if ((orange + b) >= s and (orange + b) <= t) else 0 for orange in oranges]))

 

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

[HackerRank-python] Between Two Sets  (0) 2022.07.02
[HackerRank-python] Number Line Jumps  (0) 2022.07.01
[HackerRank-python] Grading Students  (0) 2022.06.29
백준 7569번(python)  (0) 2020.08.02
백준 7576번(python)  (0) 2020.08.02
def gradingStudents(grades):
    # Write your code here
    result = []
    for grade in grades:
        if grade < 38:
            result.append(grade)
        else:
            r = grade % 5
            grade = grade + (5 - r) if r > 2 else grade
            result.append(grade)
            
    return result

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

[HackerRank-python] Number Line Jumps  (0) 2022.07.01
[HackerRank-python] Apple and Orange  (0) 2022.06.29
백준 7569번(python)  (0) 2020.08.02
백준 7576번(python)  (0) 2020.08.02
백준 2606번(python)  (0) 2020.08.01
-- (1)
SELECT T1.ANIMAL_ID
    , T1.ANIMAL_TYPE
    , T1.NAME
    FROM ANIMAL_INS T1
        INNER JOIN ANIMAL_OUTS T2
            ON T1.ANIMAL_ID = T2.ANIMAL_ID
                AND T1.SEX_UPON_INTAKE <> T2.SEX_UPON_OUTCOME

-- (2)
SELECT T1.ANIMAL_ID
    , T1.ANIMAL_TYPE
    , T1.NAME
    FROM ANIMAL_OUTS T1
        INNER JOIN ANIMAL_INS T2
            ON T1.ANIMAL_ID = T2.ANIMAL_ID
            
    WHERE SUBSTRING_INDEX(T2.SEX_UPON_INTAKE, ' ', 1) = 'Intact'
        AND SUBSTRING_INDEX(T1.SEX_UPON_OUTCOME, ' ', 1) IN ('Neutered', 'Spayed')
            
    ORDER BY ANIMAL_ID


WITH RECURSIVE A AS (
    SELECT 0 AS HOUR
    UNION ALL
    SELECT 1 + A.HOUR
      FROM A
      WHERE A.HOUR < 23
     )

SELECT T2.HOUR, COUNT(T1.HOUR) AS COUNT
    FROM (SELECT DATE_FORMAT(DATETIME, '%H') AS HOUR
          FROM ANIMAL_OUTS
          ) T1
        RIGHT JOIN A T2
               ON T1.HOUR = T2.HOUR
    GROUP BY T2.HOUR
    ORDER BY T2.HOUR