From 41908561b218bd6d1cda4109a7e0016003d64c74 Mon Sep 17 00:00:00 2001 From: Samuel Shuert Date: Thu, 2 Oct 2025 19:45:38 +0000 Subject: [PATCH] fix: routeCipher2 more small fixes --- python/oct2/level4/routeCipher2.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/oct2/level4/routeCipher2.py b/python/oct2/level4/routeCipher2.py index de1b1c0..9e1b4cb 100644 --- a/python/oct2/level4/routeCipher2.py +++ b/python/oct2/level4/routeCipher2.py @@ -1,5 +1,5 @@ from math import ceil - +from string import ascii_lowercase def getIndex(row: int, col: int, rows: int) -> int: return col*rows + row @@ -10,11 +10,11 @@ def getRowAndCol(x: int, rows: int) -> tuple[int, int]: def encodeRouteCipher(message: str, rows: int) -> str: - cur_char = "z" + cur_char = 0 row_len = ceil(len(message) / rows) while len(message) % rows != 0: - message += cur_char - cur_char = chr(ord(cur_char) - 1) + message += list(reversed(ascii_lowercase))[cur_char] + cur_char += 1 encoded_string = "" for i in range(len(message)): row, col = getRowAndCol(i, row_len) -- 2.51.2