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 |
Tags
- 코딩테스트합격자되기
- 테코테코
- json-server
- createSlice
- maeil-mail
- Get
- JavaScript
- java
- react-router
- react-redux
- redux-toolkit
- redux
- sw expert academy
- programmers
- 리액트
- SW
- C++
- redux-saga
- Python
- 이코테
- useDispatch
- 알고리즘
- 항해99
- 프로그래머스
- 매일메일
- 항해플러스
- react
- axios
- Algorithm
- 자바
Archives
- Today
- Total
Binary Journey
[프로그래머스] n 진수 게임 본문
반응형
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges
** Python
def n_decimal(n, q):
base = "0123456789ABCDEF" # 나올 수 있는 값
n, mod = divmod(n, q)
if n == 0:
return base[mod]
return n_decimal(n, q) + base[mod] # 나머지 index를 이용하여 string 더하기
def solution(n, t, m, p):
answer = ''
temp = ''
for i in range(m * t): # 나올 수 있는 모든 string 개수 = m 명 * t 개
temp += n_decimal(i, n)
while len(answer) < t:
answer += temp[p-1]
p += m # m 명 다 돌고 튜브의 순서가 돌아옴
return answer
반응형
'프로그래머스 > level 2' 카테고리의 다른 글
[프로그래머스] 가장 큰 정사각형 찾기 (0) | 2021.12.27 |
---|---|
[프로그래머스] 구명보트 (0) | 2021.12.20 |
[프로그래머스] 다음 큰 숫자 (0) | 2021.12.07 |
[프로그래머스] 올바른 괄호 (0) | 2021.12.07 |
[프로그래머스] 땅따먹기 (0) | 2021.12.06 |