백준 1855번: 암호 #Python

ColorlessDia·2024년 4월 23일

algorithm/baekjoon

목록 보기
154/807
K = int(input())
ciphertext = input()

table = []

for i in range(0, len(ciphertext), K * 2):
    if i + K <= len(ciphertext):
        table.append(ciphertext[i:i + K])

    if i + (K * 2) <= len(ciphertext):
        table.append(ciphertext[i + K:i + (K * 2)][::-1])

plaintext = ''

for j in range(K):
    for char in table:
        plaintext += char[j]

print(plaintext)

0개의 댓글