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
회고