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 |
Tags
- css #html
- Python #Baekjoon
- Next
- CSS
- react
- Default parameter
- Nullish Coalescing Operator
- Hooks
- 카카오맵 api
- firebase
- es11
- nextjs
- es6
- JavaScript
- React Kakao map
- spread operation
- optional chanining
- HTML
- Python #CodeUp
- BOJ
- 카카오맵
- Template literals
- Python
- HTML #CSS
- 프로그래머스
- Redux
- React #Hooks
Archives
- Today
- Total
거북이개발자
[프로그래머스] 124 나라의 숫자 본문
0. 제목
- 프로그래머스 124 나라의 숫자
1. 문제
https://programmers.co.kr/learn/courses/30/lessons/12899
코딩테스트 연습 - 124 나라의 숫자
programmers.co.kr
2. 풀이
- 결국 1, 2, 4를 반복해서 올라가는 과정이다.
- 4, 1, 2를 3진법의 0, 1, 2에 대응한다.
- 4일경우는 나눈몫에서 -1을 해야한다.
3. 코드
def solution(n):
answer = ''
while n:
n, nam=divmod(n,3)
answer="412"[nam]+answer
if not nam:
n -= 1
return answer