2024-12-01

Suhyeon Lee·2024년 12월 1일
0

자기주도학습

목록 보기
61/83

CodeKata

SQL

138. Weather Observation Station 6

  • 작성한 쿼리
SELECT
  DISTINCT city
FROM
  station
WHERE
  city REGEXP '^A|^E|^I|^O|^U'
;

139. Weather Observation Station 7

  • 작성한 쿼리
SELECT
  DISTINCT city
FROM
  station
WHERE
  city REGEXP 'a$|e$|i$|o$|u$'
;

140. Weather Observation Station 8

  • 작성한 쿼리
SELECT
  DISTINCT city
FROM
  station
WHERE
  city REGEXP '^[aeiou]'
  AND city REGEXP'[aeiou]$'
;

Python

56. 과일 장수

  • 작성한 코드
def solution(k, m, score):
    return sum(sorted(score)[len(score)%m::m])*m

참고할 만한 다른 풀이

solution = lambda _, m, s: sum(sorted(s)[-m::-m]) * m
def solution(k, m, score):
    answer = 0
    score.sort(reverse=True)
    apple_box = []
    for i in range(0, len(score), m):
        apple_box.append(score[i:i+m])
    for apple in apple_box:
        if len(apple) == m:
            answer += min(apple) * m

    return answer
def solution(k, m, score):
    '''
    result = 0
    score.sort(reverse = True)
    while len(score) >= m:
        result += score[:m][-1] * m
        score = score[m:]

    return result
    '''

    result = 0
    score.sort(reverse = True)
    for i in range(m - 1, len(score), m):
        result += score[i] * m

    return result
def solution(k, m, score):
    answer = 0

    score.sort()

    length = len(score)

    start_point = length % m

    while start_point < length:
        answer += score[start_point] * m
        start_point += m

    return answer
def solution(k, m, score):
    answer = 0
    a = []
    for i in sorted(score, reverse=True):
        a.append(i)
        if len(a) == m:
            answer += a[-1] * m
            a = []
    return answer

회고

  • 몸 상태가 안 좋아서 코드카타만 했음
profile
2 B R 0 2 B

0개의 댓글

관련 채용 정보