sw expert academy-1926. 간단한 369게임-python

cosmos·2022년 4월 7일
0
post-thumbnail

풀이

  • 문제를 꼼꼼히 읽어야하는 문제이다.
  • 예를 들어 365는 --5가 아닌 --가 되어야한다.
  • range로 입력받은 수까지 string형으로 초기화한 후, 반복문으로 순회하면서 접근하면 된다.

코드

# https://swexpertacademy.com/main/solvingProblem/solvingProblem.do
# sw expert academy, d2: 1926. 간단한 369게임, python3
import sys

input = sys.stdin.readline

def solve(n: int) -> list:
    nums = [str(x) for x in range(1, n+1)]

    for x in range(n):
        trans = ''
        for y in nums[x]:
            if y in ['3', '6', '9']:
                trans += '-'
                nums[x] = trans

    return nums

if __name__ == '__main__':
    n = int(input())

    print(*solve(n))

결과

출처 & 깃허브

sw expert acadmey 1926. 간단한 369게임
github

0개의 댓글