일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- hadoop safe mode
- 이더리움 #ethereum
- hadoop safe mode leave
- hive beeline
- hive beeline 설정
- mac hadoop 설정
- mac hive 3
- 자소서 너무 오래 걸림
- Resources are low on NN
- 기업 조사 빨리 하는 법
- 도커 교과서
- Safe mode is ON
- 자소서 빨리
- mac hadoop
- 카카오 2020 코테
- Could not open client transport with JDBC Uri: jdbc:hive2://localhost:10000
- is not allowed to impersonate hive (state=08S01
- mac hive
- 백준 18428
- code=0)
- hive beeline 에러
- 카카오 자물쇠와 열쇠
- 카카오 2020 코딩테스트
- mac hadoop 3
- mac hadoop 설치
- 자소서 빨리 쓰는 법
- 자소서 시간 줄이기
- Failed to connect to localhost:10000
- hive beeline 실행
- 이더리움
- Today
- Total
A seeker after truth
exercism raindrops solution 본문
P)
Your task is to convert a number into a string that contains raindrop sounds corresponding to certain potential factors. A factor is a number that evenly divides into another number, leaving no remainder. The simplest way to test if a one number is a factor of another is to use the [modulo operation](https://en.wikipedia.org/wiki/Modulo_operation).
The rules of `raindrops` are that if a given number:
- has 3 as a factor, add 'Pling' to the result.
- has 5 as a factor, add 'Plang' to the result.
- has 7 as a factor, add 'Plong' to the result.
- _does not_ have any of 3, 5, or 7 as a factor, the result should be the digits of the number.
## Examples
- 28 has 7 as a factor, but not 3 or 5, so the result would be "Plong".
- 30 has both 3 and 5 as factors, but not 7, so the result would be "PlingPlang".
- 34 is not factored by 3, 5, or 7, so the result would be "34".
sol1)
drops = ((3,'Pling'), (5,'Plang'), (7,'Plong'))
def convert(n):
"""Converts a number to a string according to the raindrop sounds."""
speak = [s for f, s in drops if n % f == 0]
return "".join(speak) if speak else str(n)
'Algorithm > 문제풀이' 카테고리의 다른 글
백준 1753 메모리 초과 오류 났던 이유 (0) | 2021.12.01 |
---|---|
프로그래머스 정렬 문제(2) (작성중) (0) | 2020.01.25 |
exercism RNA-transcription solution (0) | 2020.01.24 |
exercism pangram solution (0) | 2020.01.24 |
exercism leap solution (0) | 2020.01.24 |