250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- 통계학
- 다중공선성
- 시각화
- 한줄for문
- Leetcode
- SQL
- 선형회귀
- 리스트
- Til
- 반복문
- DATE_SUB
- Set
- ★
- 내일배움일지
- 프로그래머스
- 내배캠_학습기록
- map
- Max
- 내일배움캠프
- 아티클스터디
- SQLD
- python
- 가설검정
- 이중for문
- 데이터전처리
- AB테스트
- f-string
- 태블로
- Join
- 데이터시각화
Archives
- Today
- Total
노력에는 지름길이 없으니까요
LeetCode - 1837. Sum of Digits in Base K (Python ver.) 본문
728x90
해결일 | 언어 | 레벨 | 테스트명 |
20240916 | Python | easy | 1837. Sum of Digits in Base K |
링크 : https://leetcode.com/problems/sum-of-digits-in-base-k/
n진수로 바꾸는 법.
내 코드
class Solution:
def sumBase(self, n: int, k: int) -> int:
answer = ''
while n :
answer += str(n%k)
n //= k
return sum(int(i) for i in answer[::-1])
728x90
반응형
'Python > 프로그래머스' 카테고리의 다른 글
LeetCode - 1748. Sum of Unique Elements (Python ver.) (0) | 2024.09.16 |
---|---|
LeetCode - 1967. Number of Strings That Appear as Substrings in Word (1) | 2024.09.13 |
LeetCode - 13. Roman to Integer (Python ver.) (0) | 2024.09.06 |
LeetCode - 9. Palindrome Number (Python ver.) (0) | 2024.09.04 |
프로그래머스 - (★) 숫자의 표현 (Python ver.) (0) | 2024.09.03 |