이호진
swea 1926 - 간단한 369게임 - 2021/05/11 본문
T = int(input())
for test_case in range(1, T + 1):
n=int(input())
result=[]
for i in range(1,n+1):
if len(str(i))==1:
if i%3==0:
result.append('-')
else:
result.append(i)
elif len(str(i))==2:
if int(str(i)[0])%3==0 and int(str(i)[1])%3!=0:
result.append('-')
elif int(str(i)[0])%3!=0 and int(str(i)[1])%3==0:
result.append('-')
elif int(str(i)[0])%3==0 and int(str(i)[1])%3==0:
result.append('--')
else:
result.append(i)
elif len(str(i))==3:
if int(str(i)[0])%3==0 and int(str(i)[1])%3==0 and int(str(i)[3])%3!=0:
result.append('--')
elif int(str(i)[0])%3==0 and int(str(i)[1])%3!=0 and int(str(i)[3])%3==0:
result.append('--')
elif int(str(i)[0])%3!=0 and int(str(i)[1])%3==0 and int(str(i)[3])%3==0:
result.append('--')
elif int(str(i)[0])%3!=0 and int(str(i)[1])%3!=0 and int(str(i)[3])%3==0:
result.append('-')
elif int(str(i)[0])%3!=0 and int(str(i)[1])%3==0 and int(str(i)[3])%3!=0:
result.append('-')
elif int(str(i)[0])%3==0 and int(str(i)[1])%3!=0 and int(str(i)[3])%3!=0:
result.append('-')
elif int(str(i)[0])%3==0 and int(str(i)[1])%3==0 and int(str(i)[3])%3==0:
result.append('---')
else:
result.append(i)
elif len(str(i)) == 3:
result.append(i)
result.append(' ')
result.pop()
for i in result:
print(i,end='')
오늘부터 swea에 있는 문제를 풀기 시작했다. 제출할 때, 테스트케이스가 주어져있어서 조금 복잡하게 느껴졌다. 처음에 조금 헤맨거 말고는 다른 저지사이트와 크게 다르지 않은것같다.
'SWEA문제풀이' 카테고리의 다른 글
swea 1970 - 쉬운 거스름돈 - 2021/05/12 (0) | 2021.05.12 |
---|---|
swea 1989 - 초심자의 회문 검사 - 2021/05/12 (0) | 2021.05.12 |
swea 1979 - 어디에 단어가 들어갈 수 있을까 - 2021/05/12 (0) | 2021.05.12 |
swea 2001 - 파리 퇴치 - 2021/05/12 (0) | 2021.05.12 |
swea 2007 - 패턴 마디의 길이 - 2021/05/11 (0) | 2021.05.11 |