[프로그래머스 Level 0, Python3] 문자열 밀기


[프로그래머스 Level 0, Python3] 문자열 밀기

문제 : 문자열 밀기 풀이 방법 문자열을 밀어서 있으면 밀었던 횟수를 반환 아니면 -1 반환 소스 코드 def solution(A, B): answer = -1 tmpList = ['' for i in range(len(A))] for i in range(len(A)): for u in range(len(A)): if u+i >= len(tmpList): tmpList[u+i - len(tmpList)] = A[u] else: tmpList[u+i] = A[u] if ''.join(tmpList) == B: answer = i break return answer


원문링크 : [프로그래머스 Level 0, Python3] 문자열 밀기