Created
April 1, 2023 13:31
-
-
Save Ppang0405/252c6355d35d80130b7166e9e6b31187 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
all_string = string.ascii_lowercase | |
list_string = list(string.ascii_lowercase) | |
riddle = "QJDB PDL GL AHP SKLP QKH" | |
print(riddle.lower()) | |
def convert_letter_to_number(): | |
nums = [] | |
for letter in riddle.lower(): | |
if letter in list_string: | |
idx = list_string.index(letter) | |
nums.append(idx + 1) | |
print(nums) | |
# convert_letter_to_number() | |
def print_all_possible_sentences(): | |
for (index, item) in enumerate(list_string): | |
if item != riddle.lower()[0]: | |
correct_sentence = "" | |
for letter in riddle.lower(): | |
if letter != " ": | |
next_idx = list_string.index(letter) + int(index) | |
if next_idx >= len(list_string) + 1: | |
next_idx = next_idx - len(list_string) | |
# print(next_idx) | |
# if len(list_string) + 1 > next_idx: | |
# correct_sentence += list_string[next_idx] | |
# else: | |
# correct_sentence += list_string[next_idx - len(list_string)] | |
try: | |
correct_sentence += list_string[next_idx] | |
except: | |
correct_sentence += list_string[next_idx - len(list_string)] | |
else: | |
correct_sentence += " " | |
print(correct_sentence) | |
print_all_possible_sentences() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment