SWEA

[python][SWEA][D2] 1926. 간단한 369게임

haju 2023. 5. 16. 16:01

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&problemLevel=3&contestProbId=AV5PTeo6AHUDFAUq&categoryId=AV5PTeo6AHUDFAUq&categoryType=CODE&problemTitle=&orderBy=PASS_RATE&selectCodeLang=PYTHON&select-1=3&pageSize=10&pageIndex=7 

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

✅ 문제 풀이

  • 처음에는  29일 경우, 2-라고 출력하란 줄 알고 문제를 잘못 이해해서 시간낭비함
  • 29일 경우에는 그냥 - 로 출력하고, 36일 경우엔 --, 369일땐 --- 이런 식
n=int(input())
for i in range(1,n+1):
    num=0
    zn=i
    while i!=0:
        tmp=i%10
        if tmp==3 or tmp==6 or tmp==9:
            num+=1
        i//=10
    l = '-'
    l *= num
    if num==0:
        print(zn,end=' ')
    else:
        print(l,end=' ')