이호진

swea 1926 - 간단한 369게임 - 2021/05/11 본문

SWEA문제풀이

swea 1926 - 간단한 369게임 - 2021/05/11

이호진 2021. 5. 11. 22:55
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에 있는 문제를 풀기 시작했다. 제출할 때, 테스트케이스가 주어져있어서 조금 복잡하게 느껴졌다. 처음에 조금 헤맨거 말고는 다른 저지사이트와 크게 다르지 않은것같다.