alpha = {10: 'A', 11: 'B', 12: 'C', 13: 'D', 14: 'E', 15: 'F'}
def solution(n, t, m, p):
all = ''
count = 0
needs = p
for _ in range(t-1):
needs += m
while True:
if len(all) > needs:
break
all_temp = ''
temp = count
while True:
k = temp % n
if k in alpha:
k = alpha[k]
all_temp = str(k) + all_temp
if temp // n != 0:
temp = temp // n
else:
break
all += all_temp
count += 1
answer = ''
for i in range(p-1, (t-1)*m+p, m):
answer += str(all[i])
return answer
2018 카카오 블라인드 3차 - 1번
1. needs (필요한 배열의 총 길이)만큼 총배열(all_temp)를 만든다
- temp를 0부터 순서대로 해당 진법(n)으로 만들어준다.
- 16진수 일 경우 딕셔너리를 이용해서 변경
2. answer에 p부터 m씩증가한 수 t개를 넣는다
3. answer출력
최대한 빨리 풀려고 하다보니 난잡해졌다
'Algorithm > 프로그래머스' 카테고리의 다른 글
[프로그래머스] - 파일명 정렬 (파이썬) (0) | 2022.02.06 |
---|---|
[프로그래머스] - 압축 (파이썬) (0) | 2022.02.06 |
[프로그래머스] - 추석 트랙픽 (파이썬) (0) | 2022.01.30 |
[프로그래머스] - 프렌즈4블록 (파이썬) (0) | 2022.01.30 |
[프로그래머스] - 뉴스 클러스터링 (파이썬) (0) | 2022.01.30 |