728x90
def solution(food):
answer = ''
for i in range(1,len(food)) :
for j in range(food[i] // 2) :
answer += str(i)
reversed_str = "".join(reversed(answer))
answer += '0'
answer += reversed_str
return answer
풀이 및 회고
food 배열을 순회해 해당하는 숫자를 추가해줍니다. 그 후 뒤집는 문자열을 준비하고 가운데 0 을 붙여줍니다.
728x90
'프로그래머스' 카테고리의 다른 글
프로그래머스 LV 3 단어 변환 (0) | 2024.06.28 |
---|---|
프로그래머스 LV 3 네트워크 (0) | 2024.06.28 |
프로그래머스 LV1 숫자 짝궁 (0) | 2024.06.27 |
프로그래머스 LV2 2 x n 타일링 (0) | 2024.06.26 |
프로그래머스 LV 1 과일장수 (0) | 2024.06.26 |