CMU Coding Bootcamp

fix: routeCipher2 more small fixes

thecoded.prof 41908561 81e279d8

verified
Changed files
+4 -4
python
oct2
+4 -4
python/oct2/level4/routeCipher2.py
··· 1 1 from math import ceil 2 - 2 + from string import ascii_lowercase 3 3 4 4 def getIndex(row: int, col: int, rows: int) -> int: 5 5 return col*rows + row ··· 10 10 11 11 12 12 def encodeRouteCipher(message: str, rows: int) -> str: 13 - cur_char = "z" 13 + cur_char = 0 14 14 row_len = ceil(len(message) / rows) 15 15 while len(message) % rows != 0: 16 - message += cur_char 17 - cur_char = chr(ord(cur_char) - 1) 16 + message += list(reversed(ascii_lowercase))[cur_char] 17 + cur_char += 1 18 18 encoded_string = "" 19 19 for i in range(len(message)): 20 20 row, col = getRowAndCol(i, row_len)