Skip to content

Commit fc0ff55

Browse files
committed
[BOJ] #1855. 암호 / 브론즈1 / 41분 / 성공
1 parent 158a9c6 commit fc0ff55

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
n = int(input()) # 열의 개수
5+
cipher_txt = input().strip() # 암호화 된 문자
6+
rows = len(cipher_txt) // n # 행의 개수
7+
8+
# 리스트에 채워넣기
9+
arr = []
10+
for i in range(rows):
11+
if i % 2 == 0: # 왼 -> 오
12+
arr.append(cipher_txt[i*n:(i+1)*n])
13+
else: # 오 -> 왼
14+
arr.append(cipher_txt[i*n:(i+1)*n][::-1])
15+
16+
# 원래의 문자열 복원
17+
original = ""
18+
for i in range(n):
19+
for j in range(rows):
20+
original += arr[j][i]
21+
print(original)

0 commit comments

Comments
 (0)