728x90
5356번: Triangles
Read in a letter and a number. The number indicates how big the letter triangle should be. The number indicating the size of the triangle will have a range from 0 to 250 (i.e., num>=0 and num<=250). The letters must wrap around from Z to A. If you start wi
www.acmicpc.net
문제 풀이
이 문제도 단순한 출력 문제이다. 미리 A부터 Z까지를 순서대로 문자열에 추가한 뒤에 사용해준다. 만약 출력하다가 Z이상으로 인덱스가 넘어간다면, 다시 인덱스를 0으로 만들어서 처음부터 돌아갈 수 있도록 해준다.
정답 코드
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for _ in range(int(input())) :
n, l = input().split()
idx = alpha.index(l)
for i in range(1, int(n) + 1) :
print(alpha[idx] * i)
idx += 1
if idx == 26 : idx = 0
print()
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 5691 - 평균 중앙값 문제 [python] (1) | 2023.03.15 |
---|---|
[BOJ/백준] 5666 - Hot Dogs [python] (0) | 2023.03.15 |
[BOJ/백준] 5342 - Billing [python] (0) | 2023.03.15 |
[BOJ/백준] 5340 - Secret Location [python] (0) | 2023.03.15 |
[BOJ/백준] 5292 - Counting Swann’s Coins [python] (1) | 2023.03.15 |