CMU Coding Bootcamp

fix: small name fixes

thecoded.prof 81e279d8 2ab905d9

verified
Changed files
+6 -6
python
oct2
+6 -6
python/oct2/level4/routeCipher2.py
··· 1 1 from math import ceil 2 2 3 3 4 - def f(row: int, col: int, rows: int) -> int: 4 + def getIndex(row: int, col: int, rows: int) -> int: 5 5 return col*rows + row 6 6 7 7 8 - def i_f(x: int, rows: int) -> tuple[int, int]: 8 + def getRowAndCol(x: int, rows: int) -> tuple[int, int]: 9 9 return x // rows, x % rows 10 10 11 11 ··· 17 17 cur_char = chr(ord(cur_char) - 1) 18 18 encoded_string = "" 19 19 for i in range(len(message)): 20 - row, col = i_f(i, row_len) 21 - encoded_string += message[f(row, col, rows)] 20 + row, col = getRowAndCol(i, row_len) 21 + encoded_string += message[getIndex(row, col, rows)] 22 22 encoded_message = f"{rows}" 23 23 for i in range(0, rows): 24 24 if i % 2 == 0: ··· 40 40 else: 41 41 decoded_string += encoded_string[i*row_len:(i+1)*row_len][::-1] 42 42 for i in range(len(decoded_string)): 43 - row, col = i_f(i, rows) 44 - decoded_message += decoded_string[f(row, col, row_len)] 43 + row, col = getRowAndCol(i, rows) 44 + decoded_message += decoded_string[getIndex(row, col, row_len)] 45 45 while decoded_message[-1].islower(): 46 46 decoded_message = decoded_message[:-1] 47 47 return decoded_message