반응형
Given a string of digits, you should replace any digit below 5 with '0' and any digit 5 and above with '1'. Return the resulting string.
Note: input will never be an empty string
Solution:
def fake_bin(x): return ''.join(str(int(i) >= 5 and 1 or 0) for i in x)
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0913. Take the Derivative (0) | 2022.09.13 |
---|---|
알고리즘 포스팅 관련 공지 (0) | 2022.09.13 |
0911. Add Length (0) | 2022.09.11 |
0910. Quarter of the year (0) | 2022.09.10 |
0909. Will there be enough space? (0) | 2022.09.09 |