70.0% ≤ sim ≤ 100%

WORDLE

27 clusters, 159 submissions

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #1(4)

# 6130394021 sim = 100.0% import random import string def position_in_word(ch, word): position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return '' def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text return colored_text# 6331007021 sim = 100.0% import random import string def position_in_word(ch, word): position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return '' def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text return colored_text# 6331230621 sim = 100.0% import random import string def position_in_word(ch, word): position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return '' def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text return colored_text# 6432186021 sim = 88.68% import random import string def position_in_word(ch, word): position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = '' new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return '' def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' return text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #2(27)

# 6430348021 sim = 98.76% import random import string def position_in_word(ch, word): if word[0] == ch : position = 0 elif word[1] == ch : position = 1 elif word[2] == ch : position = 2 elif word[3] == ch : position = 3 elif word[4] == ch : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = "" correct = "" new_puzzle_word = "" if guess_word[0] == puzzle_word[0] : new_guess_word += '-' correct += puzzle_word[0] new_puzzle_word += '-' else : new_guess_word += guess_word[0] correct += '?' new_puzzle_word += puzzle_word[0] if guess_word[1] == puzzle_word[1] : new_guess_word += '-' correct += puzzle_word[1] new_puzzle_word += '-' else : new_guess_word += guess_word[1] correct += '?' new_puzzle_word += puzzle_word[1] if guess_word[2] == puzzle_word[2] : new_guess_word += '-' correct += puzzle_word[2] new_puzzle_word += '-' else : new_guess_word += guess_word[2] correct += '?' new_puzzle_word += puzzle_word[2] if guess_word[3] == puzzle_word[3] : new_guess_word += '-' correct += puzzle_word[3] new_puzzle_word += '-' else : new_guess_word += guess_word[3] correct += '?' new_puzzle_word += puzzle_word[3] if guess_word[4] == puzzle_word[4] : new_guess_word += '-' correct += puzzle_word[4] new_puzzle_word += '-' else : new_guess_word += guess_word[4] correct += '?' new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0] : wrong_position = wrong_position + guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') else: wrong_position = wrong_position + "*" if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: wrong_position = wrong_position + guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),'-') else: wrong_position = wrong_position + "*" if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: wrong_position = wrong_position + guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') else: wrong_position = wrong_position + "*" if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: wrong_position = wrong_position + guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') else: wrong_position = wrong_position + "*" if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: wrong_position = wrong_position + guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') else: wrong_position = wrong_position + "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): x = '' if k == 0 : x = '-' + original_str[1:5:] elif k == 1 : x = original_str[0:1:] + ch + original_str[2:5:] elif k == 2 : x = original_str[0:2:] + ch + original_str[3:5:] elif k == 3 : x = original_str[0:3:] + ch + original_str[4:5:] elif k == 4 : x = original_str[0:4:] + ch return x def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m'# 6430364021 sim = 98.76% import random import string def position_in_word(ch, word): if word[0] == ch : position = 0 elif word[1] == ch : position = 1 elif word[2] == ch : position = 2 elif word[3] == ch : position = 3 elif word[4] == ch : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = "" correct = "" new_puzzle_word = "" if guess_word[0] == puzzle_word[0] : new_guess_word += '-' correct += puzzle_word[0] new_puzzle_word += '-' else : new_guess_word += guess_word[0] correct += '?' new_puzzle_word += puzzle_word[0] if guess_word[1] == puzzle_word[1] : new_guess_word += '-' correct += puzzle_word[1] new_puzzle_word += '-' else : new_guess_word += guess_word[1] correct += '?' new_puzzle_word += puzzle_word[1] if guess_word[2] == puzzle_word[2] : new_guess_word += '-' correct += puzzle_word[2] new_puzzle_word += '-' else : new_guess_word += guess_word[2] correct += '?' new_puzzle_word += puzzle_word[2] if guess_word[3] == puzzle_word[3] : new_guess_word += '-' correct += puzzle_word[3] new_puzzle_word += '-' else : new_guess_word += guess_word[3] correct += '?' new_puzzle_word += puzzle_word[3] if guess_word[4] == puzzle_word[4] : new_guess_word += '-' correct += puzzle_word[4] new_puzzle_word += '-' else : new_guess_word += guess_word[4] correct += '?' new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0] : wrong_position = wrong_position + guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') else: wrong_position = wrong_position + "*" if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: wrong_position = wrong_position + guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),'-') else: wrong_position = wrong_position + "*" if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: wrong_position = wrong_position + guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') else: wrong_position = wrong_position + "*" if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: wrong_position = wrong_position + guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') else: wrong_position = wrong_position + "*" if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: wrong_position = wrong_position + guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') else: wrong_position = wrong_position + "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): x = '' if k == 0 : x = '-' + original_str[1:5:] elif k == 1 : x = original_str[0:1:] + ch + original_str[2:5:] elif k == 2 : x = original_str[0:2:] + ch + original_str[3:5:] elif k == 3 : x = original_str[0:3:] + ch + original_str[4:5:] elif k == 4 : x = original_str[0:4:] + ch return x def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text return colored_text# 6430168321 sim = 87.33% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_guess_word = '-' correct = puzzle_word[0] new_puzzle_word = '-' if guess_word[0] != puzzle_word[0]: new_guess_word = guess_word[0] correct = '?' new_puzzle_word = puzzle_word[0] if guess_word[1] == puzzle_word[1]: new_guess_word += '-' correct += puzzle_word[1] new_puzzle_word += '-' if guess_word[1] != puzzle_word[1]: new_guess_word += guess_word[1] correct += '?' new_puzzle_word += puzzle_word[1] if guess_word[2] == puzzle_word[2]: new_guess_word += '-' correct += puzzle_word[2] new_puzzle_word += '-' if guess_word[2] != puzzle_word[2]: new_guess_word += guess_word[2] correct += '?' new_puzzle_word += puzzle_word[2] if guess_word[3] == puzzle_word[3]: new_guess_word += '-' correct += puzzle_word[3] new_puzzle_word += '-' if guess_word[3] != puzzle_word[3]: new_guess_word += guess_word[3] correct += '?' new_puzzle_word += puzzle_word[3] if guess_word[4] == puzzle_word[4]: new_guess_word += '-' correct += puzzle_word[4] new_puzzle_word += '-' if guess_word[4] != puzzle_word[4]: new_guess_word += guess_word[4] correct += '?' new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0] : wrong_position = guess_word[0] x = position_in_word(guess_word[0], puzzle_word) puzzle_word = puzzle_word[:x:] + '!' + puzzle_word[x+1::] else: wrong_position = '*' if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1] : wrong_position += guess_word[1] x = position_in_word(guess_word[1], puzzle_word) puzzle_word = puzzle_word[:x:] + '!' + puzzle_word[x+1::] else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2] : wrong_position += guess_word[2] x = position_in_word(guess_word[2], puzzle_word) puzzle_word = puzzle_word[:x:] + '!' + puzzle_word[x+1::] else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3] : wrong_position += guess_word[3] x = position_in_word(guess_word[3], puzzle_word) puzzle_word = puzzle_word[:x:] + '!' + puzzle_word[x+1::] else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4] : wrong_position += guess_word[4] else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0: x = ch + original_str[1::] elif k == 1: x = original_str[0] + ch +original_str[2::] elif k == 2: x = original_str[:2:] + ch + original_str[3::] elif k == 3: x = original_str[:3:] + ch + original_str[4] elif k == 4: x = original_str[:4:] + ch return x def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green': if text[0] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': colored_text += white_on_green + text[0] + normal else: colored_text += text[0] if text[1] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': colored_text += white_on_green + text[1] + normal else: colored_text += text[1] if text[2] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': colored_text += white_on_green + text[2] + normal else: colored_text += text[2] if text[3] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': colored_text += white_on_green + text[3] + normal else: colored_text += text[3] if text[4] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': colored_text += white_on_green + text[4] + normal else: colored_text += text[4] if color == 'yellow': if text[0] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if text[1] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if text[2] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': colored_text += white_on_yellow+ text[2] + normal else: colored_text += text[2] if text[3] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if text[4] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text# 6430180821 sim = 87.33% import random import string def position_in_word(ch, word): position = -1 if ch==word[0]: position=0 elif ch==word[1]: position=1 elif ch==word[2]: position=2 elif ch==word[3]: position=3 elif ch==word[4]: position=4 else: pass return position def check_correct_position(puzzle_word, guess_word): new_guess_word ="" correct = "" new_puzzle_word = "" if guess_word[0]==puzzle_word[0]: new_guess_word+="-" correct+=puzzle_word[0] new_puzzle_word+="-" else: new_guess_word+=guess_word[0] correct+="?" new_puzzle_word+=puzzle_word[0] if guess_word[1]==puzzle_word[1]: new_guess_word+="-" correct+=puzzle_word[1] new_puzzle_word+="-" else: new_guess_word+=guess_word[1] correct+="?" new_puzzle_word+=puzzle_word[1] if guess_word[2]==puzzle_word[2]: new_guess_word+="-" correct+=puzzle_word[2] new_puzzle_word+="-" else: new_guess_word+=guess_word[2] correct+="?" new_puzzle_word+=puzzle_word[2] if guess_word[3]==puzzle_word[3]: new_guess_word+="-" correct+=puzzle_word[3] new_puzzle_word+="-" else: new_guess_word+=guess_word[3] correct+="?" new_puzzle_word+=puzzle_word[3] if guess_word[4]==puzzle_word[4]: new_guess_word+="-" correct+=puzzle_word[4] new_puzzle_word+="-" else: new_guess_word+=guess_word[4] correct+="?" new_puzzle_word+=puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0]!="-": wrong_position+=guess_word[0] cut=position_in_word(guess_word[0],puzzle_word) puzzle_word=puzzle_word[0:cut:]+puzzle_word[cut+1::] else: wrong_position+="*" if guess_word[1] in puzzle_word and guess_word[1]!="-": wrong_position+=guess_word[1] cut=position_in_word(guess_word[1],puzzle_word) puzzle_word=puzzle_word[0:cut:]+puzzle_word[cut+1::] else: wrong_position+="*" if guess_word[2] in puzzle_word and guess_word[2]!="-": wrong_position+=guess_word[2] cut=position_in_word(guess_word[2],puzzle_word) puzzle_word=puzzle_word[0:cut:]+puzzle_word[cut+1::] else: wrong_position+="*" if guess_word[3] in puzzle_word and guess_word[3]!="-": wrong_position+=guess_word[3] cut=position_in_word(guess_word[3],puzzle_word) puzzle_word=puzzle_word[0:cut:]+puzzle_word[cut+1::] else: wrong_position+="*" if guess_word[4] in puzzle_word and guess_word[4]!="-": wrong_position+=guess_word[4] cut=position_in_word(guess_word[4],puzzle_word) puzzle_word=puzzle_word[0:cut:]+puzzle_word[cut+1::] else: wrong_position+="*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k==0: new_string=ch+original_str[1::] elif k==1: new_string=original_str[0]+ch+original_str[2::] elif k==2: new_string=original_str[0:2:]+ch+original_str[3::] elif k==3: new_string=original_str[0:3:]+ch+original_str[4::] elif k==4: new_string=original_str[::-1]+ch return new_string def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text="" if color=="green": if text[0] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": colored_text+=white_on_green+text[0]+normal else: colored_text+=text[0] if text[1] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": colored_text+=white_on_green+text[1]+normal else: colored_text+=text[1] if text[2] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": colored_text+=white_on_green+text[2]+normal else: colored_text+=text[2] if text[3] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": colored_text+=white_on_green+text[3]+normal else: colored_text+=text[3] if text[4] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": colored_text+=white_on_green+text[4]+normal else: colored_text+=text[4] if color=="yellow": if text[0] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": colored_text+=white_on_yellow+text[0]+normal else: colored_text+=text[0] if text[1] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": colored_text+=white_on_yellow+text[1]+normal else: colored_text+=text[1] if text[2] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": colored_text+=white_on_yellow+text[2]+normal else: colored_text+=text[2] if text[3] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": colored_text+=white_on_yellow+text[3]+normal else: colored_text+=text[3] if text[4] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": colored_text+=white_on_yellow+text[4]+normal else: colored_text+=text[4] return colored_text# 6430212221 sim = 78.05% import random import string def position_in_word(ch, word): position = -1 if ch in word[0] : position = 0 elif ch in word[1] : position = 1 elif ch in word[2]: position = 2 elif ch in word[3]: position = 3 elif ch in word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = '' new_puzzle_word = '' correct = '' if puzzle_word[0] == guess_word[0]: correct += guess_word[0] new_puzzle_word += '-' new_guess_word += '-' else : correct += '?' new_puzzle_word += puzzle_word[0] new_guess_word += guess_word[0] if puzzle_word[1] == guess_word[1]: correct += guess_word[1] new_puzzle_word += '-' new_guess_word += '-' else : correct += '?' new_puzzle_word += puzzle_word[1] new_guess_word += guess_word[1] if puzzle_word[2] == guess_word[2]: correct += guess_word[2] new_puzzle_word += '-' new_guess_word += '-' else : correct += '?' new_puzzle_word += puzzle_word[2] new_guess_word += guess_word[2] if puzzle_word[3] == guess_word[3]: correct += guess_word[3] new_puzzle_word += '-' new_guess_word += '-' else : correct += '?' new_puzzle_word += puzzle_word[3] new_guess_word += guess_word[3] if puzzle_word[4] == guess_word[4]: correct += guess_word[4] new_puzzle_word += '-' new_guess_word += '-' else : correct += '?' new_puzzle_word += puzzle_word[4] new_guess_word += guess_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if (guess_word[0] in puzzle_word) and (guess_word[0] != puzzle_word[0]) : wrong_position += guess_word[0] piw=position_in_word(guess_word[0],puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word, piw, '-') else : wrong_position += '*' if (guess_word[1] in puzzle_word) and (guess_word[1] != puzzle_word[1]) : wrong_position += guess_word[1] piw=position_in_word(guess_word[1],puzzle_word) puzzle_word =replace_kth_letter_in_str(puzzle_word, piw, '-') else : wrong_position += '*' if (guess_word[2] in puzzle_word) and (guess_word[2] != puzzle_word[2]) : wrong_position += guess_word[2] piw=position_in_word(guess_word[2],puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word, piw, '-') else : wrong_position += '*' if (guess_word[3] in puzzle_word) and (guess_word[3] != puzzle_word[3]) : wrong_position += guess_word[3] piw=position_in_word(guess_word[3],puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word, piw, '-') else : wrong_position += '*' if (guess_word[4] in puzzle_word) and (guess_word[4] != puzzle_word[4]) : wrong_position += guess_word[4] piw=position_in_word(guess_word[4],puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word, piw, '-') else : wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0 : letter_replace = ch + original_str[1:] elif k == 1 : letter_replace = original_str[0] + ch + original_str[2:] elif k == 2 : letter_replace = original_str[0:2] + ch + original_str[3:] elif k == 3 : letter_replace = original_str[0:3] + ch + original_str[4] elif k == 4 : letter_replace = original_str[0:4] + ch return '' + letter_replace def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if (text[0] != '*') and (text[0] != '?') : if color == 'green' : ch0 = white_on_green + text[0] + normal elif color == 'yellow' : ch0 = white_on_yellow + text[0] + normal else : ch0 = text[0] if (text[1] != '*') and (text[1] != '?') : if color == 'green' : ch1 = white_on_green + text[1] + normal elif color == 'yellow' : ch1 = white_on_yellow + text[1] + normal else : ch1 = text[1] if (text[2] != '*') and (text[2] != '?') : if color == 'green' : ch2 = white_on_green + text[2] + normal elif color == 'yellow' : ch2 = white_on_yellow + text[2] + normal else : ch2 = text[2] if (text[3] != '*') and (text[3] != '?') : if color == 'green' : ch3 = white_on_green + text[3] + normal elif color == 'yellow' : ch3 = white_on_yellow + text[3] + normal else : ch3 = text[3] if (text[4] != '*') and (text[4] != '?') : if color == 'green' : ch4 = white_on_green + text[4] + normal elif color == 'yellow' : ch4 = white_on_yellow + text[4] + normal else : ch4 = text[4] text = ''+ ch0 + ch1 +ch2 + ch3 + ch4 colored_text = text return colored_text# 6430352421 sim = 78.05% import random import string def position_in_word(ch, word): position = -1 if word[0]== ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '' new_guess_word = '' new_puzzle_word = "" if puzzle_word[0]== guess_word[0]: correct += puzzle_word[0] new_guess_word += '-' new_puzzle_word += "-" else: correct += '?' new_guess_word += puzzle_word[0] new_puzzle_word += puzzle_word[0] if puzzle_word[1]== guess_word[1]: correct += puzzle_word[1] new_guess_word += '-' new_puzzle_word += "-" else: correct += '?' new_guess_word += puzzle_word[1] new_puzzle_word += puzzle_word[1] if puzzle_word[2]== guess_word[2]: correct += puzzle_word[2] new_guess_word += '-' new_puzzle_word += "-" else: correct += '?' new_guess_word += puzzle_word[2] new_puzzle_word += puzzle_word[2] if puzzle_word[3]== guess_word[3]: correct += puzzle_word[3] new_guess_word += '-' new_puzzle_word += "-" else: correct += '?' new_guess_word += puzzle_word[3] new_puzzle_word += puzzle_word[3] if puzzle_word[4]== guess_word[4]: correct += puzzle_word[4] new_guess_word += '-' new_puzzle_word += "-" else: correct += '?' new_guess_word += puzzle_word[4] new_puzzle_word += puzzle_word[4] return correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0]: x = position_in_word(guess_word[0], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, x, "-") wrong_position += guess_word[0] else: if guess_word[0] == puzzle_word[0]: wrong_position += '*' else: wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: x = position_in_word(guess_word[1], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, x, "-") wrong_position += guess_word[1] else: if guess_word[1] == puzzle_word[1]: wrong_position += '*' else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: x = position_in_word(guess_word[2], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, x, "-") wrong_position += guess_word[2] else: if guess_word[2] == puzzle_word[2]: wrong_position += '*' else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: x = position_in_word(guess_word[3], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, x, "-") wrong_position += guess_word[3] else: if guess_word[3] == puzzle_word[3]: wrong_position += '*' else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: x = position_in_word(guess_word[4], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, x, "-") wrong_position += guess_word[4] else: if guess_word[4] == puzzle_word[4]: wrong_position += '*' else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0: original_str = ch + original_str[1:] elif k == 1: original_str = original_str[0] + ch + original_str[2:] elif k == 2: original_str = original_str[:2] + ch + original_str[3:] elif k == 3: original_str = original_str[:3] + ch + original_str[4] elif k == 4: original_str = original_str[:4] + ch return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text[0] != '*' and text[0] != '?': if color == 'green': colored_text += white_on_green + text[0] + normal else: colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if text[1] != '*' and text[1] != '?': if color == 'green': colored_text += white_on_green + text[1] + normal else: colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if text[2] != '*' and text[2] != '?': if color == 'green': colored_text += white_on_green + text[2] + normal else: colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if text[3] != '*' and text[3] != '?': if color == 'green': colored_text += white_on_green + text[3] + normal else: colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if text[4] != '*' and text[4] != '?': if color == 'green': colored_text += white_on_green + text[4] + normal else: colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text# 6430217421 sim = 75.48% import random import string def position_in_word(ch, word): if word[0] == ch : position = 0 elif word[1] == ch : position = 1 elif word[2] == ch : position = 2 elif word[3] == ch : position = 3 elif word[4] == ch : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = "" correct = "" new_puzzle_word = "" if guess_word[0] == puzzle_word[0] : new_guess_word += '-' correct += puzzle_word[0] new_puzzle_word += '-' else : new_guess_word += guess_word[0] correct += '?' new_puzzle_word += puzzle_word[0] if guess_word[1] == puzzle_word[1] : new_guess_word += '-' correct += puzzle_word[1] new_puzzle_word += '-' else : new_guess_word += guess_word[1] correct += '?' new_puzzle_word += puzzle_word[1] if guess_word[2] == puzzle_word[2] : new_guess_word += '-' correct += puzzle_word[2] new_puzzle_word += '-' else : new_guess_word += guess_word[2] correct += '?' new_puzzle_word += puzzle_word[2] if guess_word[3] == puzzle_word[3] : new_guess_word += '-' correct += puzzle_word[3] new_puzzle_word += '-' else : new_guess_word += guess_word[3] correct += '?' new_puzzle_word += puzzle_word[3] if guess_word[4] == puzzle_word[4] : new_guess_word += '-' correct += puzzle_word[4] new_puzzle_word += '-' else : new_guess_word += guess_word[4] correct += '?' new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0] : wrong_position = wrong_position + guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') else: wrong_position = wrong_position + "*" if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: wrong_position = wrong_position + guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),'-') else: wrong_position = wrong_position + "*" if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: wrong_position = wrong_position + guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') else: wrong_position = wrong_position + "*" if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: wrong_position = wrong_position + guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') else: wrong_position = wrong_position + "*" if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: wrong_position = wrong_position + guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') else: wrong_position = wrong_position + "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): x = '' if k == 0 : x = '-' + original_str[1:5:] elif k == 1 : x = original_str[0:1:] + ch + original_str[2:5:] elif k == 2 : x = original_str[0:2:] + ch + original_str[3:5:] elif k == 3 : x = original_str[0:3:] + ch + original_str[4:5:] elif k == 4 : x = original_str[0:4:] + ch return x def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = "" if text[0] != '*' and text[0] !='?' : if color == 'green' : colored_text += white_on_green + text[0] + normal if color == 'yellow' : colored_text += white_on_yellow + text[0] + normal else : colored_text += text[0] if text[1] != '*' and text[1] != '?' : if color == 'green' : colored_text += white_on_green + text[1] + normal if color == 'yellow' : colored_text += white_on_yellow + text[1] + normal else : colored_text += text[1] if text[2] != '*' and text[2] != '?' : if color == 'green' : colored_text += white_on_green + text[2] + normal if color == 'yellow' : colored_text += white_on_yellow + text[2] + normal else : colored_text += text[2] if text[3] != '*' and text[3] != '?' : if color == 'green' : colored_text += white_on_green + text[3] + normal if color == 'yellow' : colored_text += white_on_yellow + text[3] + normal else : colored_text += text[3] if text[4] != '*' and text[4] != '?' : if color == 'green' : colored_text += white_on_green + text[4] + normal if color == 'yellow' : colored_text += white_on_yellow + text[4] + normal else : colored_text += text[4] return colored_text# 6430397721 sim = 75.48% import random import string def position_in_word(ch, word): position = -1 if ch==word[0]: position = 0 elif ch==word[1]: position = 1 elif ch==word[2]: position = 2 elif ch==word[3]: position = 3 elif ch==word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '' new_guess_word = '' new_puzzle_word = '' if puzzle_word[0] == guess_word[0] : correct = correct + puzzle_word[0] new_guess_word = new_guess_word + '-' new_puzzle_word = new_puzzle_word + '-' else: correct = correct + '?' new_guess_word = new_guess_word + guess_word[0] new_puzzle_word = new_puzzle_word + puzzle_word[0] if puzzle_word[1] == guess_word[1] : correct = correct + puzzle_word[1] new_guess_word = new_guess_word + '-' new_puzzle_word = new_puzzle_word + '-' else: correct = correct + '?' new_guess_word = new_guess_word + guess_word[1] new_puzzle_word = new_puzzle_word + puzzle_word[1] if puzzle_word[2] == guess_word[2] : correct = correct + puzzle_word[2] new_guess_word = new_guess_word + '-' new_puzzle_word = new_puzzle_word + '-' else: correct = correct + '?' new_guess_word = new_guess_word + guess_word[2] new_puzzle_word = new_puzzle_word + puzzle_word[2] if puzzle_word[3] == guess_word[3] : correct = correct + puzzle_word[3] new_guess_word = new_guess_word + '-' new_puzzle_word = new_puzzle_word + '-' else: correct = correct + '?' new_guess_word = new_guess_word + guess_word[3] new_puzzle_word = new_puzzle_word + puzzle_word[3] if puzzle_word[4] == guess_word[4] : correct = correct + puzzle_word[4] new_guess_word = new_guess_word + '-' new_puzzle_word = new_puzzle_word + '-' else: correct = correct + '?' new_guess_word = new_guess_word + guess_word[4] new_puzzle_word = new_puzzle_word + puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != '-': wrong_position = wrong_position + guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0], puzzle_word),'-') else: wrong_position = wrong_position + '*' if guess_word[1] in puzzle_word and guess_word[1] != '-': wrong_position = wrong_position + guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1], puzzle_word),'-') else: wrong_position = wrong_position + '*' if guess_word[2] in puzzle_word and guess_word[2] != '-': wrong_position = wrong_position + guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2], puzzle_word),'-') else: wrong_position = wrong_position + '*' if guess_word[3] in puzzle_word and guess_word[3] != '-': wrong_position = wrong_position + guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3], puzzle_word),'-') else: wrong_position = wrong_position + '*' if guess_word[4] in puzzle_word and guess_word[4] != '-': wrong_position = wrong_position + guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[4], puzzle_word),'-') else: wrong_position = wrong_position + '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): original_str = original_str[:k] + ch + original_str[k+1:] return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text[0] != '*' and text[0] != '?': if color == 'green': ch0 = white_on_green + text[0] + normal if color == 'yellow': ch0 = white_on_yellow + text[0] + normal else: ch0 = text[0] if text[1] != '*' and text[1] != '?': if color == 'green': ch1 = white_on_green + text[1] + normal if color == 'yellow': ch1 = white_on_yellow + text[1] + normal else: ch1 = text[1] if text[2] != '*' and text[2] != '?': if color == 'green': ch2 = white_on_green + text[2] + normal if color == 'yellow': ch2 = white_on_yellow + text[2] + normal else: ch2 = text[2] if text[3] != '*' and text[3] != '?': if color == 'green': ch3 = white_on_green + text[3] + normal if color == 'yellow': ch3 = white_on_yellow + text[3] + normal else: ch3 = text[3] if text[4] != '*' and text[4] != '?': if color == 'green': ch4 = white_on_green + text[4] + normal if color == 'yellow': ch4 = white_on_yellow + text[4] + normal else: ch4 = text[4] text = ch0+ch1+ch2+ch3+ch4 return text# 6432139521 sim = 74.57% import random import string def position_in_word(ch, word): position = -1 if ch==word[0]: position = 0 elif ch==word[1]: position = 1 elif ch==word[2]: position = 2 elif ch==word[3]: position = 3 elif ch==word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '' new_puzzle_word = '' new_guess_word = '' if puzzle_word[0] == guess_word[0]: correct += puzzle_word[0] new_puzzle_word += '-' new_guess_word += '-' else: correct += '?' new_puzzle_word += puzzle_word[0] new_guess_word += guess_word[0] if puzzle_word[1] == guess_word[1]: correct += puzzle_word[1] new_puzzle_word += '-' new_guess_word += '-' else: correct += '?' new_puzzle_word += puzzle_word[1] new_guess_word += guess_word[1] if puzzle_word[2] == guess_word[2]: correct += puzzle_word[2] new_puzzle_word += '-' new_guess_word += '-' else: correct += '?' new_puzzle_word += puzzle_word[2] new_guess_word += guess_word[2] if puzzle_word[3] == guess_word[3]: correct += puzzle_word[3] new_puzzle_word += '-' new_guess_word += '-' else: correct += '?' new_puzzle_word += puzzle_word[3] new_guess_word += guess_word[3] if puzzle_word[4] == guess_word[4]: correct += puzzle_word[4] new_puzzle_word += '-' new_guess_word += '-' else: correct += '?' new_puzzle_word += puzzle_word[4] new_guess_word += guess_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != "-": wrong_position += guess_word[0] puzzle_word= replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0],puzzle_word), '*') else: wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != "-": wrong_position += guess_word[1] puzzle_word= replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1],puzzle_word), '*') else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != "-": wrong_position += guess_word[2] puzzle_word= replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2],puzzle_word), '*') else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != "-": wrong_position += guess_word[3] puzzle_word= replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3],puzzle_word), '*') else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != "-": wrong_position += guess_word[4] puzzle_word= replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4],puzzle_word), '*') else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): an='' if k == 0 : an= ch+ original_str[1::1] if k == 1 : an= original_str[0]+ch+ original_str[2::1] if k == 2 : an= original_str[0:2]+ch+ original_str[-2::1] if k == 3 : an= original_str[0:3]+ch+ original_str[-1] if k == 4 : an= original_str[0:4]+ch return an def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green': col = white_on_green else: col = white_on_yellow if text[0] != '?' and text[0] != '*': colored_text += col + text[0] + normal else : colored_text += text[0] if text[1] != '?' and text[1] != '*': colored_text += col + text[1] + normal else : colored_text += text[1] if text[2] != '?' and text[2] != '*': colored_text += col + text[2] + normal else : colored_text += text[2] if text[3] != '?' and text[3] != '*': colored_text += col + text[3] + normal else : colored_text += text[3] if text[4] != '?' and text[4] != '*': colored_text += col + text[4] + normal else : colored_text += text[4] return colored_text# 6430360421 sim = 73.64% import random import string def position_in_word(ch, word): if ch in word[0]: position=0 elif ch in word[1]: position=1 elif ch in word[2]: position=2 elif ch in word[3]: position=3 elif ch in word[4]: position=4 else: position=-1 return position def check_correct_position(puzzle_word, guess_word): correct='' b="?"*5 c="-"*5 if guess_word[0]==puzzle_word[0] and guess_word[0]!="-": correct=puzzle_word[0]+b[1:5] b=correct guess_word="-"+guess_word[1:5] puzzle_word="-"+puzzle_word[1:5] if guess_word[1]==puzzle_word[1] and guess_word[1]!="-": correct=b[0]+puzzle_word[1]+b[2:5] b=correct guess_word=guess_word[0]+"-"+guess_word[2:5] puzzle_word=puzzle_word[0]+"-"+puzzle_word[2:5] if guess_word[2]==puzzle_word[2] and guess_word[2]!="-": correct=b[0:2]+puzzle_word[2]+b[3:5] b=correct guess_word=guess_word[0:2]+"-"+guess_word[3:5] puzzle_word=puzzle_word[0:2]+"-"+puzzle_word[3:5] if guess_word[3]==puzzle_word[3] and guess_word[3]!="-": correct=b[0:3]+puzzle_word[3]+b[4:5] b=correct guess_word=guess_word[0:3]+"-"+guess_word[4:5] puzzle_word=puzzle_word[0:3]+"-"+puzzle_word[4:5] if guess_word[4]==puzzle_word[4] and guess_word[4]!="-": correct=b[0:4]+puzzle_word[4] b=correct guess_word=guess_word[0:4]+"-" puzzle_word=puzzle_word[0:4]+"-" else: correct=b new_guess_word=guess_word new_puzzle_word=puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): d="*"*5 if (guess_word[0] in puzzle_word) and guess_word[0] !="-": d=guess_word[0]+d[1:5] puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), '-') if (guess_word[1] in puzzle_word) and guess_word[1] !="-": d=d[0]+guess_word[1]+d[2:5] puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), '-') if (guess_word[2] in puzzle_word) and guess_word[2] !="-": d=d[0:2]+guess_word[2]+d[3:5] puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), '-') if (guess_word[3] in puzzle_word) and guess_word[3] !="-": d=d[0:3]+guess_word[3]+d[4:5] puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), '-') if (guess_word[4] in puzzle_word) and guess_word[4] !="-": d=d[0:4]+guess_word[4] puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), '-') wrong_position=d return wrong_position def replace_kth_letter_in_str(original_str, k, ch): new_str='' if k==0: new_str=ch+original_str[1:5] if k==1: new_str=original_str[0]+ch+original_str[2:5] if k==2: original_str=original_str[0:2]+ch+original_str[3:5] if k==3: new_str=original_str[0:3]+ch+original_str[4] if k==4: new_str=original_str[0:5]+ch return new_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color=="green": if text[0:1] != "?": a=white_on_green + text[0:1] + normal else: a=text[0:1] if text[1:2] != "?": b=white_on_green + text[1:2] + normal else: b=text[1:2] if text[2:3] != "?": c=white_on_green + text[2:3] + normal else: c=text[2:3] if text[3:4] != "?": d=white_on_green + text[3:4] + normal else: d=text[3:4] if text[4:5] != "?": e=white_on_green + text[4:5] + normal else: e=text[4:5] text=a+b+c+d+e else: if text[0:1] != "*": a=white_on_yellow + text[0:1] + normal else: a=text[0:1] if text[1:2] != "*": b=white_on_yellow + text[1:2] + normal else: b=text[1:2] if text[2:3] != "*": c=white_on_yellow + text[2:3] + normal else: c=text[2:3] if text[3:4] != "*": d=white_on_yellow + text[3:4] + normal else: d=text[3:4] if text[4:5] != "*": e=white_on_yellow + text[4:5] + normal else: e=text[4:5] text=a+b+c+d+e colored_text = text return colored_text# 6430390221 sim = 73.64% import random import string def position_in_word(ch, word): position = -1 if ch in word[0]: position = 0 elif ch in word[1]: position = 1 elif ch in word[2]: position = 2 elif ch in word[3]: position = 3 elif ch in word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if puzzle_word[0]==guess_word[0]: correct = puzzle_word[0] + correct[1:] new_puzzle_word = '-' + puzzle_word[1:] new_guess_word = '-' + guess_word[1:] if puzzle_word[1]==guess_word[1]: correct = correct[0] + puzzle_word[1] + correct[2:] new_puzzle_word = new_puzzle_word[0] + '-' + puzzle_word[2:] new_guess_word = new_guess_word[0] + '-' + guess_word[2:] if puzzle_word[2]==guess_word[2]: correct = correct[0:2] + puzzle_word[2] + correct[3:] new_puzzle_word = new_puzzle_word[0:2] + '-' + puzzle_word[3:] new_guess_word = new_guess_word[0:2] + '-' + guess_word[3:] if puzzle_word[3]==guess_word[3]: correct = correct[0:3] + puzzle_word[3] + correct[4] new_puzzle_word = new_puzzle_word[0:3] + '-' + puzzle_word[4] new_guess_word = new_guess_word[0:3] + '-' + guess_word[4] if puzzle_word[4]==guess_word[4]: correct = correct[:4] + puzzle_word[4] new_puzzle_word = new_puzzle_word[:4] + '-' new_guess_word = new_guess_word[:4] + '-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if 'A'<=guess_word[0]<='Z' and guess_word[0] in puzzle_word: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word) , '-') if 'A'<=guess_word[1]<='Z' and guess_word[1] in puzzle_word: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word) , '-') if 'A'<=guess_word[2]<='Z' and guess_word[2] in puzzle_word: wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word) , '-') if 'A'<=guess_word[3]<='Z' and guess_word[3] in puzzle_word: wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word) , '-') if 'A'<=guess_word[4]<='Z' and guess_word[4] in puzzle_word: wrong_position = wrong_position[0:4] + guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word) , '-') return wrong_position def replace_kth_letter_in_str(original_str, k, ch): ch = '-' if k==0: replace_str = ch + original_str[1:] elif k==1: replace_str = original_str[0] + ch + original_str[2:] elif k==2: replace_str = original_str[0:2] + ch + original_str[3:] elif k==3: replace_str = original_str[0:3] + ch + original_str[4] else: replace_str = original_str[0:4] + ch return replace_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text if color=='green': if 'A'<=text[0]<='Z': c0 = white_on_green + text[0] + normal if text[0]<'A': c0 = text[0] if 'A'<=text[1]<='Z': c1 = white_on_green + text[1] + normal if text[1]<'A': c1 = text[1] if 'A'<=text[2]<='Z': c2 = white_on_green + text[2] + normal if text[2]<'A': c2 = text[2] if 'A'<=text[3]<='Z': c3 = white_on_green + text[3] + normal if text[3]<'A': c3 = text[3] if 'A'<=text[4]<='Z': c4 = white_on_green + text[4] + normal if text[4]<'A': c4 = text[4] else: if 'A'<=text[0]<='Z': c0 = white_on_yellow + text[0] + normal if text[0]<'A': c0 = text[0] if 'A'<=text[1]<='Z': c1 = white_on_yellow + text[1] + normal if text[1]<'A': c1 = text[1] if 'A'<=text[2]<='Z': c2 = white_on_yellow + text[2] + normal if text[2]<'A': c2 = text[2] if 'A'<=text[3]<='Z': c3 = white_on_yellow + text[3] + normal if text[3]<'A': c3 = text[3] if 'A'<=text[4]<='Z': c4 = white_on_yellow + text[4] + normal if text[4]<'A': c4 = text[4] colored_text = c0+c1+c2+c3+c4 return colored_text# 6231216821 sim = 73.06% import random import string def position_in_word(ch, word): if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): if guess_word[0] == puzzle_word[0] : ch0 = True else : ch0 = False if guess_word[1] == puzzle_word[1] : ch1 = True else : ch1 = False if guess_word[2] == puzzle_word[2] : ch2 = True else : ch2 = False if guess_word[3] == puzzle_word[3] : ch3 = True else : ch3 = False if guess_word[4] == puzzle_word[4] : ch4 = True else : ch4 = False new_guess_word = '' correct = '' new_puzzle_word = '' if ch0 : new_guess_word += "-" correct += guess_word[0] new_puzzle_word += "-" else : new_guess_word += guess_word[0] correct += "?" new_puzzle_word += puzzle_word[0] if ch1 : new_guess_word += "-" correct += guess_word[1] new_puzzle_word += "-" else : new_guess_word += guess_word[1] correct += "?" new_puzzle_word += puzzle_word[1] if ch2 : new_guess_word += "-" correct += guess_word[2] new_puzzle_word += "-" else : new_guess_word += guess_word[2] correct += "?" new_puzzle_word += puzzle_word[2] if ch3 : new_guess_word += "-" correct += guess_word[3] new_puzzle_word += "-" else : new_guess_word += guess_word[3] correct += "?" new_puzzle_word += puzzle_word[3] if ch4 : new_guess_word += "-" correct += guess_word[4] new_puzzle_word += "-" else : new_guess_word += guess_word[4] correct += "?" new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if (guess_word[0] != "-") and (guess_word[0] in puzzle_word) : wrong_position += guess_word[0] pos = position_in_word(guess_word[0],puzzle_word) puzzle_word = puzzle_word[0:pos:]+puzzle_word[pos+1::] else : wrong_position += "*" if (guess_word[1] != "-") and (guess_word[1] in puzzle_word) : wrong_position += guess_word[1] pos = position_in_word(guess_word[1],puzzle_word) puzzle_word = puzzle_word[0:pos:]+puzzle_word[pos+1::] else : wrong_position += "*" if (guess_word[2] != "-") and (guess_word[2] in puzzle_word) : wrong_position += guess_word[2] pos = position_in_word(guess_word[2],puzzle_word) puzzle_word = puzzle_word[0:pos:]+puzzle_word[pos+1::] else : wrong_position += "*" if (guess_word[3] != "-") and (guess_word[3] in puzzle_word) : wrong_position += guess_word[3] pos = position_in_word(guess_word[3],puzzle_word) puzzle_word = puzzle_word[0:pos:]+puzzle_word[pos+1::] else : wrong_position += "*" if (guess_word[4] != "-") and (guess_word[4] in puzzle_word) : wrong_position += guess_word[4] pos = position_in_word(guess_word[4],puzzle_word) puzzle_word = puzzle_word[0:pos:]+puzzle_word[pos+1::] else : wrong_position += "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): a = original_str[:k:] + ch + original_str[k+1::] return a def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == "green" : if text[0] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : ch0 = white_on_green + text[0] + normal else : ch0 = text[0] if text[1] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : ch1 = white_on_green + text[1] + normal else : ch1 = text[1] if text[2] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : ch2 = white_on_green + text[2] + normal else : ch2 = text[2] if text[3] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : ch3 = white_on_green + text[3] + normal else : ch3 = text[3] if text[4] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : ch4 = white_on_green + text[4] + normal else : ch4 = text[4] else : if text[0] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : ch0 = white_on_yellow + text[0] + normal else : ch0 = text[0] if text[1] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : ch1 = white_on_yellow + text[1] + normal else : ch1 = text[1] if text[2] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : ch2 = white_on_yellow + text[2] + normal else : ch2 = text[2] if text[3] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : ch3 = white_on_yellow + text[3] + normal else : ch3 = text[3] if text[4] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : ch4 = white_on_yellow + text[4] + normal else : ch4 = text[4] colored_text = ch0+ch1+ch2+ch3+ch4 return colored_text# 6430225421 sim = 72.29% import random import string def position_in_word(ch, word): if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = '' correct = '' new_puzzle_word = '' if puzzle_word[0] == guess_word[0] : new_guess_word += '-' correct += guess_word[0] new_puzzle_word += '-' else : new_guess_word += guess_word[0] correct += '?' new_puzzle_word += puzzle_word[0] if puzzle_word[1] == guess_word[1] : new_guess_word += '-' correct += guess_word[1] new_puzzle_word += '-' else : new_guess_word += guess_word[1] correct += '?' new_puzzle_word += puzzle_word[1] if puzzle_word[2] == guess_word[2] : new_guess_word += '-' correct += guess_word[2] new_puzzle_word += '-' else : new_guess_word += guess_word[2] correct += '?' new_puzzle_word += puzzle_word[2] if puzzle_word[3] == guess_word[3] : new_guess_word += '-' correct += guess_word[3] new_puzzle_word += '-' else : new_guess_word += guess_word[3] correct += '?' new_puzzle_word += puzzle_word[3] if puzzle_word[4] == guess_word[4] : new_guess_word += '-' correct += guess_word[4] new_puzzle_word += '-' else : new_guess_word += guess_word[4] correct += '?' new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): words = '' if guess_word[0] in puzzle_word : words += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), '$') else : words += '*' if guess_word[1] in puzzle_word : words += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), '$') else : words += '*' if guess_word[2] in puzzle_word : words += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), '$') else : words += '*' if guess_word[3] in puzzle_word : words += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), '$') else : words += '*' if guess_word[4] in puzzle_word : words += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), '$') else : words += '*' return words def replace_kth_letter_in_str(original_str, k, ch): word = '' if k == 0 : word = ch + original_str[1:5] elif k == 4 : word = original_str[0:4] + ch else : word = original_str[0:k] + ch + original_str[k+1:5] return word def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ctext = '' c = '' white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == 'yellow' : c = white_on_yellow elif color == 'green' : c = white_on_green if text[0] in alphabet : ctext += c + text[0] + normal else : ctext += text[0] if text[1] in alphabet : ctext += c + text[1] + normal else : ctext += text[1] if text[2] in alphabet : ctext += c + text[2] + normal else : ctext += text[2] if text[3] in alphabet : ctext += c + text[3] + normal else : ctext += text[3] if text[4] in alphabet : ctext += c + text[4] + normal else : ctext += text[4] return ctext# 6430441621 sim = 72.29% import random import string def position_in_word(ch, word): position = -1 if ch in word: if ch in word[0]: position=0 elif ch in word[1]: position=1 elif ch in word[2]: position=2 elif ch in word[3]: position=3 elif ch in word[4]: position=4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = '' correct = '' new_puzzle_word = '' if guess_word[0]==puzzle_word[0] : new_guess_word +='-' correct +=guess_word[0] new_puzzle_word +='-' else: new_guess_word +=guess_word[0] correct +='?' new_puzzle_word +=puzzle_word[0] if guess_word[1]==puzzle_word[1] : new_guess_word +='-' correct +=guess_word[1] new_puzzle_word +='-' else: new_guess_word +=guess_word[1] correct +='?' new_puzzle_word +=puzzle_word[1] if guess_word[2]==puzzle_word[2] : new_guess_word +='-' correct +=guess_word[2] new_puzzle_word +='-' else: new_guess_word +=guess_word[2] correct +='?' new_puzzle_word +=puzzle_word[2] if guess_word[3]==puzzle_word[3] : new_guess_word +='-' correct +=guess_word[3] new_puzzle_word +='-' else: new_guess_word +=guess_word[3] correct +='?' new_puzzle_word +=puzzle_word[3] if guess_word[4]==puzzle_word[4] : new_guess_word +='-' correct +=guess_word[4] new_puzzle_word +='-' else: new_guess_word +=guess_word[4] correct +='?' new_puzzle_word +=puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word: wrong_position +=guess_word[0] puzzle_word=replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'0') else: wrong_position +='*' if guess_word[1] in puzzle_word: wrong_position +=guess_word[1] puzzle_word=replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),'0') else: wrong_position +='*' if guess_word[2] in puzzle_word: wrong_position +=guess_word[2] puzzle_word=replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2],puzzle_word),'0') else: wrong_position +='*' if guess_word[3] in puzzle_word: wrong_position +=guess_word[3] puzzle_word=replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3],puzzle_word),'0') else: wrong_position +='*' if guess_word[4] in puzzle_word: wrong_position +=guess_word[4] puzzle_word=replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[4],puzzle_word),'0') else: wrong_position +='*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): x=list(original_str) if k == 0: x[0]=ch elif k == 1: x[1]=ch elif k == 2: x[2]=ch elif k == 3: x[3]=ch elif k == 4: x[4]=ch y=str(''.join(x)) return y def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' x=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] if color == 'green': if text[0] in x: a=white_on_green+text[0]+normal else: a=text[0] if text[1] in x: b=white_on_green+text[1]+normal else: b=text[1] if text[2] in x: c=white_on_green+text[2]+normal else: c=text[2] if text[3] in x: d=white_on_green+text[3]+normal else: d=text[3] if text[4] in x: e=white_on_green+text[4]+normal else: e=text[4] text=a+b+c+d+e colored_text = text elif color == 'yellow': if text[0] in x: a=white_on_yellow+text[0]+normal else: a=text[0] if text[1] in x: b=white_on_yellow+text[1]+normal else: b=text[1] if text[2] in x: c=white_on_yellow+text[2]+normal else: c=text[2] if text[3] in x: d=white_on_yellow+text[3]+normal else: d=text[3] if text[4] in x: e=white_on_yellow+text[4]+normal else: e=text[4] text=a+b+c+d+e colored_text = text return colored_text# 6430292421 sim = 71.85% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: correct += guess_word[0] new_guess_word += '-' new_puzzle_word += '-' else: correct += '?' new_guess_word += guess_word[0] new_puzzle_word += puzzle_word[0] if puzzle_word[1] == guess_word[1]: correct += guess_word[1] new_guess_word += '-' new_puzzle_word += '-' else: correct += '?' new_guess_word += guess_word[1] new_puzzle_word += puzzle_word[1] if puzzle_word[2] == guess_word[2]: correct += guess_word[2] new_guess_word += '-' new_puzzle_word += '-' else: correct += '?' new_guess_word += guess_word[2] new_puzzle_word += puzzle_word[2] if puzzle_word[3] == guess_word[3]: correct += guess_word[3] new_guess_word += '-' new_puzzle_word += '-' else: correct += '?' new_guess_word += guess_word[3] new_puzzle_word += puzzle_word[3] if puzzle_word[4] == guess_word[4]: correct += guess_word[4] new_guess_word += '-' new_puzzle_word += '-' else: correct += '?' new_guess_word += guess_word[4] new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word : wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0], puzzle_word), "-") else: wrong_position += '*' if guess_word[1] in puzzle_word : wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1], puzzle_word), "-") else: wrong_position += '*' if guess_word[2] in puzzle_word : wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2], puzzle_word), "-") else: wrong_position += '*' if guess_word[3] in puzzle_word : wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3], puzzle_word), "-") else: wrong_position += '*' if guess_word[4] in puzzle_word : wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[4], puzzle_word), "-") else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[0:k] + ch + original_str[k+1:] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text return colored_text# 6430237021 sim = 71.77% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_guess_word = guess_word if puzzle_word[0] == guess_word[0]: correct = puzzle_word[0] + correct[1:] puzzle_word = '-' + puzzle_word[1:] new_guess_word = '-' + new_guess_word[1:] if puzzle_word[1] == guess_word[1]: correct = correct[0] + puzzle_word[1] + correct[2:] puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] new_guess_word = new_guess_word[0] + '-' + new_guess_word[2:] if puzzle_word[2] == guess_word[2]: correct = correct[:2] + puzzle_word[2] + correct[3:] puzzle_word = puzzle_word[:2] + '-' + puzzle_word[3:] new_guess_word = new_guess_word[:2] + '-' + new_guess_word[3:] if puzzle_word[3] == guess_word[3]: correct = correct[:3] + puzzle_word[3] + correct[4:] puzzle_word = puzzle_word[:3] + '-' + puzzle_word[4:] new_guess_word = new_guess_word[:3] + '-' + new_guess_word[4:] if puzzle_word[4] == guess_word[4]: correct = correct[:4] + puzzle_word[4] puzzle_word = puzzle_word[:4] + '-' new_guess_word = new_guess_word[:4] + '-' new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0],puzzle_word), '-') if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1],puzzle_word), '-') if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2],puzzle_word), '-') if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4:] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3],puzzle_word), '-') if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: wrong_position = wrong_position[:4] + guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4],puzzle_word), '-') return wrong_position def replace_kth_letter_in_str(original_str, k, ch): original_str = original_str[:k] + ch + original_str[k+1:] return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text[0] != '?' and text[0] != '*': if color == 'green': ch = white_on_green + text[0] + normal colored_text += ch elif color == 'yellow': ch = white_on_yellow + text[0] + normal colored_text += ch else: colored_text += text[0] if text[1] != '?' and text[1] != '*': if color == 'green': ch = white_on_green + text[1] + normal colored_text += ch elif color == 'yellow': ch = white_on_yellow + text[1] + normal colored_text += ch else: colored_text += text[1] if text[2] != '?' and text[2] != '*': if color == 'green': ch = white_on_green + text[2] + normal colored_text += ch elif color == 'yellow': ch = white_on_yellow + text[2] + normal colored_text += ch else: colored_text += text[2] if text[3] != '?' and text[3] != '*': if color == 'green': ch = white_on_green + text[3] + normal colored_text += ch elif color == 'yellow': ch = white_on_yellow + text[3] + normal colored_text += ch else: colored_text += text[3] if text[4] != '?' and text[4] != '*': if color == 'green': ch = white_on_green + text[4] + normal colored_text += ch elif color == 'yellow': ch = white_on_yellow + text[4] + normal colored_text += ch else: colored_text += text[4] return colored_text# 6432136621 sim = 71.77% import random import string def position_in_word(ch, word): if ch == word[0] : position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct ='?????' new_puzzle_word = puzzle_word if puzzle_word[0]==guess_word[0] : new_guess_word = "-"+ guess_word[1:] correct = puzzle_word[0]+correct[1:] new_puzzle_word = "-"+puzzle_word[1:] if puzzle_word[1]==guess_word[1]: new_guess_word = new_guess_word[0]+"-"+new_guess_word[2:] correct = correct[0]+puzzle_word[1]+correct[2:] new_puzzle_word =new_puzzle_word[0]+"-"+new_puzzle_word[2:] if puzzle_word[2]==guess_word[2]: new_guess_word = new_guess_word[:2]+"-"+new_guess_word[3:] correct =correct[0:2]+puzzle_word[2]+correct[3:] new_puzzle_word =new_puzzle_word[:2]+"-"+new_puzzle_word[3:] if puzzle_word[3]==guess_word[3]: new_guess_word = new_guess_word[:3]+"-"+new_guess_word[-1] correct = correct[0:3]+puzzle_word[3]+correct[-1] new_puzzle_word =new_puzzle_word[:3]+"-"+new_puzzle_word[-1] if puzzle_word[4]==guess_word[4]: new_guess_word = new_guess_word[:4]+"-" correct = correct[:4]+puzzle_word[-1] new_puzzle_word =new_puzzle_word[:4]+"-" return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] in puzzle_word and guess_word[0] !=puzzle_word[0]: wrong_position = guess_word[0] + wrong_position [1:] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),"-") if guess_word[1] in puzzle_word and guess_word[1] !=puzzle_word[1] : wrong_position = wrong_position[0]+guess_word[1] + wrong_position [2:] puzzle_word = replace_kth_letter_in_str( puzzle_word, position_in_word(guess_word[1],puzzle_word),"-") if guess_word[2] in puzzle_word and guess_word[2] !=puzzle_word[2]: wrong_position = wrong_position[:2]+guess_word[2] + wrong_position [3:] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2],puzzle_word),"-") if guess_word[3] in puzzle_word and guess_word[3] !=puzzle_word[3]: wrong_position = wrong_position[:3]+guess_word[3] + wrong_position [-1] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3],puzzle_word),"-") if guess_word[4] in puzzle_word and guess_word[4] !=puzzle_word[4]: wrong_position = wrong_position[:4]+guess_word[4] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k==0 : new_original = ch+original_str[1:] else: new_original = original_str[:k]+ch+original_str[k+1:] return new_original def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == 'green': if text[0] != '?': k1 = white_on_green+text[0]+normal else: k1 = text[0] if text[1] != '?': k2= white_on_green+text[1]+normal else: k2 = text[1] if text[2] != '?': k3= white_on_green+text[2]+normal else: k3 = text[2] if text[3] != '?': k4 = white_on_green+text[3]+normal else: k4 = text[3] if text[4] != '?': k5 = white_on_green+text[4]+normal else: k5= text[4] else : if text[0] != '*': k1 = white_on_yellow+text[0]+normal else: k1 = text[0] if text[1] != '*': k2= white_on_yellow+text[1]+normal else: k2 = text[1] if text[2] != '*': k3= white_on_yellow+text[2]+normal else: k3 = text[2] if text[3] != '*': k4 = white_on_yellow+text[3]+normal else: k4 = text[3] if text[4] != '*': k5 = white_on_yellow+text[4]+normal else: k5= text[4] colored_text = k1+k2+k3+k4+k5 return colored_text# 6430197521 sim = 71.4% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: correct += guess_word[0] new_puzzle_word = '-'+new_puzzle_word[1:] new_guess_word = '-' + new_guess_word[1:] else: correct += '?' if guess_word[1] == puzzle_word[1]: correct += guess_word[1] new_puzzle_word = new_puzzle_word[0:1]+'-'+new_puzzle_word[2:] new_guess_word = new_guess_word[0:1] + '-' + new_guess_word[2:] else: correct += '?' if guess_word[2] == puzzle_word[2]: correct += guess_word[2] new_puzzle_word = new_puzzle_word[0:2]+'-'+new_puzzle_word[3:] new_guess_word = new_guess_word[0:2] + '-' + new_guess_word[3:] else: correct += '?' if guess_word[3] == puzzle_word[3]: correct += guess_word[3] new_puzzle_word = new_puzzle_word[0:3]+'-'+new_puzzle_word[4:] new_guess_word = new_guess_word[0:3] + '-' + new_guess_word[4:] else: correct += '?' if guess_word[4] == puzzle_word[4]: correct += guess_word[4] new_puzzle_word = new_puzzle_word[0:4]+'-' new_guess_word = new_guess_word[0:4] + '-' else: correct += '?' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and puzzle_word[0] != '-': wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), '*') else: wrong_position += '*' if guess_word[1] in puzzle_word and puzzle_word[1] != '-': wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), '*') else: wrong_position += '*' if guess_word[2] in puzzle_word and puzzle_word[2] != '-': wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), '*') else: wrong_position += '*' if guess_word[3] in puzzle_word and puzzle_word[3] != '-': wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), '*') else: wrong_position += '*' if guess_word[4] in puzzle_word and puzzle_word[4] != '-': wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), '*') else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return '' + original_str[:k] + ch + original_str[k+1:] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text[0] not in ['*','?']: if color == 'green': colored_text += white_on_green + text[0] + normal else: colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if text[1] not in ['*','?']: if color == 'green': colored_text += white_on_green + text[1] + normal else: colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if text[2] not in ['*','?']: if color == 'green': colored_text += white_on_green + text[2] + normal else: colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if text[3] not in ['*','?']: if color == 'green': colored_text += white_on_green + text[3] + normal else: colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if text[4] not in ['*','?']: if color == 'green': colored_text += white_on_green + text[4] + normal else: colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] if len(colored_text) == 0: colored_text = text return colored_text# 6432192721 sim = 71.26% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 if ch == word[1]: position = 1 if ch == word[2]: position = 2 if ch == word[3]: position = 3 if ch == word[4]: position = 4 else: pass return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0] : new_guess_word = '-' + guess_word[1:] correct += puzzle_word[0] new_puzzle_word = '-' + puzzle_word[1:] else : new_guess_word = puzzle_word[:] correct += '?' new_puzzle_word = puzzle_word if guess_word[1] == puzzle_word[1] : new_guess_word = new_guess_word[0] + '-' + guess_word[2:] correct += puzzle_word[1] new_puzzle_word = new_puzzle_word[0] + '-' + puzzle_word[2:] else : new_guess_word = new_guess_word[0] + guess_word[1:] correct += '?' new_puzzle_word = new_puzzle_word[0] + puzzle_word[1:] if guess_word[2] == puzzle_word[2] : new_guess_word = new_guess_word[:2] + '-' + guess_word[3:] correct += puzzle_word[2] new_puzzle_word = new_puzzle_word[:2] + '-' + puzzle_word[3:] else : new_guess_word = new_guess_word[:3] + guess_word[3:] correct += '?' new_puzzle_word = new_puzzle_word[:3] + puzzle_word[3:] if guess_word[3] == puzzle_word[3] : new_guess_word = new_guess_word[:3] + '-' + guess_word[4:] correct += puzzle_word[3] new_puzzle_word = new_puzzle_word[:3] + '-' + puzzle_word[4:] else : new_guess_word = new_guess_word[:4] + guess_word[4:] correct += '?' new_puzzle_word = new_puzzle_word[:4] + puzzle_word[4:] if guess_word[4] == puzzle_word[4] : new_guess_word = new_guess_word[:4] + '-' correct += puzzle_word[4] new_puzzle_word = new_puzzle_word[:4] + '-' else : new_guess_word = new_guess_word[:4] + guess_word[4] correct += '?' new_puzzle_word = new_puzzle_word[:4] + puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if (guess_word[0] in puzzle_word) and (guess_word[0] != '-'): wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), '-') else: wrong_position += '*' if guess_word[1] in puzzle_word and (guess_word[1] != '-'): wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), '-') else: wrong_position += '*' if guess_word[2] in puzzle_word and (guess_word[2] != '-'): wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), '-') else: wrong_position += '*' if guess_word[3] in puzzle_word and (guess_word[3] != '-'): wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), '-') else: wrong_position += '*' if guess_word[4] in puzzle_word and (guess_word[4] != '-'): wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), '-') else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k+1:] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' alp = 'QWERTYUIOPLKJHGFDSAZXCVBNM' if (text[0] in alp) and (color == 'green') : colored_text += white_on_green + text[0] + normal elif (text[0] in alp) and (color == 'yellow') : colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if (text[1] in alp) and (color == 'green') : colored_text += white_on_green + text[1] + normal elif (text[1] in alp) and (color == 'yellow') : colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if (text[2] in alp) and (color == 'green') : colored_text += white_on_green + text[2] + normal elif (text[2] in alp) and (color == 'yellow') : colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if (text[3] in alp) and (color == 'green') : colored_text += white_on_green + text[3] + normal elif (text[3] in alp) and (color == 'yellow') : colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if (text[4] in alp) and (color == 'green') : colored_text += white_on_green + text[4] + normal elif (text[4] in alp) and (color == 'yellow') : colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text# 6432150321 sim = 71.08% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = '' correct = '' new_puzzle_word = '' if guess_word[0] == puzzle_word[0]: new_guess_word += '-' correct += puzzle_word[0] new_puzzle_word += '-' else: new_guess_word += guess_word[0] correct += '?' new_puzzle_word += puzzle_word[0] if guess_word[1] == puzzle_word[1]: new_guess_word += '-' correct += puzzle_word[1] new_puzzle_word += '-' else: new_guess_word += guess_word[1] correct += '?' new_puzzle_word += puzzle_word[1] if guess_word[2] == puzzle_word[2]: new_guess_word += '-' correct += puzzle_word[2] new_puzzle_word += '-' else: new_guess_word += guess_word[2] correct += '?' new_puzzle_word += puzzle_word[2] if guess_word[3] == puzzle_word[3]: new_guess_word += '-' correct += puzzle_word[3] new_puzzle_word += '-' else: new_guess_word += guess_word[3] correct += '?' new_puzzle_word += puzzle_word[3] if guess_word[4] == puzzle_word[4]: new_guess_word += '-' correct += puzzle_word[4] new_puzzle_word += '-' else: new_guess_word += guess_word[4] correct += '?' new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != '-': wrong_position += guess_word[0] ch_del = position_in_word(guess_word[0],puzzle_word) puzzle_word = puzzle_word[0:ch_del] + '-' + puzzle_word[ch_del+1:] else: wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != '-': wrong_position += guess_word[1] ch_del = position_in_word(guess_word[1],puzzle_word) puzzle_word = puzzle_word[0:ch_del] + '-' + puzzle_word[ch_del+1:] else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != '-': wrong_position += guess_word[2] ch_del = position_in_word(guess_word[2],puzzle_word) puzzle_word = puzzle_word[0:ch_del] + '-' + puzzle_word[ch_del+1:] else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != '-': wrong_position += guess_word[3] ch_del = position_in_word(guess_word[3],puzzle_word) puzzle_word = puzzle_word[0:ch_del] + '-' + puzzle_word[ch_del+1:] else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != '-': wrong_position += guess_word[4] ch_del = position_in_word(guess_word[4],puzzle_word) puzzle_word = puzzle_word[0:ch_del] + '-' + puzzle_word[ch_del+1:] else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k+1:] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' clor = '' if color == 'green': clor = white_on_green if color == 'yellow': clor = white_on_yellow if text[0] != '?' and text[0] != '*': colored_text += clor + text[0] + normal else: colored_text += text[0] if text[1] != '?' and text[1] != '*': colored_text += clor + text[1] + normal else: colored_text += text[1] if text[2] != '?' and text[2] != '*': colored_text += clor + text[2] + normal else: colored_text += text[2] if text[3] != '?' and text[3] != '*': colored_text += clor + text[3] + normal else: colored_text += text[3] if text[4] != '?' and text[4] != '*': colored_text += clor + text[4] + normal else: colored_text += text[4] return colored_text# 6231205921 sim = 70.96% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch : position = 0 elif word[1] == ch : position = 1 elif word[2] == ch : position = 2 elif word[3] == ch : position = 3 elif word[4] == ch : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0] : new_guess_word = '-' + guess_word[1:] correct += guess_word[0] new_puzzle_word = '-' + new_puzzle_word[1:] else : correct += '?' if guess_word[1] == puzzle_word[1] : new_guess_word = new_guess_word[0] + '-' + guess_word[2:] correct += guess_word[1] new_puzzle_word = new_puzzle_word[0] + '-' + new_puzzle_word[2:] else : correct += '?' if guess_word[2] == puzzle_word[2] : new_guess_word = new_guess_word[:2] + '-' + guess_word[3:] correct += guess_word[2] new_puzzle_word = new_puzzle_word[:2] + '-' + new_puzzle_word[3:] else : correct += '?' if guess_word[3] == puzzle_word[3] : new_guess_word = new_guess_word[:3] + '-' + guess_word[4:] correct += guess_word[3] new_puzzle_word = new_puzzle_word[:3] + '-' + new_puzzle_word[4:] else : correct += '?' if guess_word[4] == puzzle_word[4] : new_guess_word = new_guess_word[:4] + '-' correct += guess_word[4] new_puzzle_word = new_puzzle_word[:4] + '-' else : correct += '?' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word : if guess_word[0] == '-' : wrong_position += '*' else : wrong_position += guess_word[0] position = position_in_word(guess_word[0], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word,position,'*') else : wrong_position += '*' if guess_word[1] in puzzle_word : if guess_word[1] == '-' : wrong_position += '*' else : wrong_position += guess_word[1] position = position_in_word(guess_word[1], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word,position,'*') else : wrong_position += '*' if guess_word[2] in puzzle_word : if guess_word[2] == '-' : wrong_position += '*' else : wrong_position += guess_word[2] position = position_in_word(guess_word[2], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word,position,'*') else : wrong_position += '*' if guess_word[3] in puzzle_word : if guess_word[3] == '-' : wrong_position += '*' else : wrong_position += guess_word[3] position = position_in_word(guess_word[3], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word,position,'*') else : wrong_position += '*' if guess_word[4] in puzzle_word : if guess_word[4] == '-' : wrong_position += '*' position = position_in_word(guess_word[0], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word,position,'*') else : wrong_position += guess_word[4] position = position_in_word(guess_word[4], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word,position,'*') else : wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): a = '' if k == 0 : a = ch + original_str[1:] if k == 1 : a = original_str[0] + ch + original_str[2:] if k == 2 : a = original_str[:2] + ch + original_str[3:] if k == 3 : a = original_str[:3] + ch + original_str[4] if k == 4 : a = original_str[:4] + ch return a def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text != '*****' and text != '?????' : if text[0] != '?' and text[0] != '*' : if color == 'green' : colored_text += white_on_green + text[0] + normal elif color == 'yellow' : colored_text += white_on_yellow + text[0] + normal else : colored_text += text[0] if text[1] != '?' and text[1] != '*' : if color == 'green' : colored_text += white_on_green + text[1] + normal elif color == 'yellow' : colored_text += white_on_yellow + text[1] + normal else : colored_text += text[1] if text[2] != '?' and text[2] != '*' : if color == 'green' : colored_text += white_on_green + text[2] + normal elif color == 'yellow' : colored_text += white_on_yellow + text[2] + normal else : colored_text += text[2] if text[3] != '?' and text[3] != '*' : if color == 'green' : colored_text += white_on_green + text[3] + normal elif color == 'yellow' : colored_text += white_on_yellow + text[3] + normal else : colored_text += text[3] if text[4] != '?' and text[4] != '*' : if color == 'green' : colored_text += white_on_green + text[4] + normal elif color == 'yellow' : colored_text += white_on_yellow + text[4] + normal else : colored_text += text[4] return colored_text else : return text# 6432167021 sim = 70.96% import random import string def position_in_word(ch, word): if word[4] == ch : position =4 if word[3] == ch : position =3 if word[2] == ch : position =2 if word[1] == ch : position =1 if word[0] == ch : position =0 position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0] : new_guess_word = '-' + new_guess_word[1:] correct = guess_word[0] + correct[1:] new_puzzle_word = '-' + puzzle_word[1:] if puzzle_word[1] == guess_word[1] : new_guess_word = new_guess_word[0] + '-' + new_guess_word[2:] correct = correct[0] + guess_word[1] + correct[2:] new_puzzle_word = new_puzzle_word[0] + '-' + puzzle_word[1:] if puzzle_word[2] == guess_word[2] : new_guess_word = new_guess_word[:2] + '-' + new_guess_word[3:] correct = correct[:2] + guess_word[2] + correct[3:] new_puzzle_word = new_puzzle_word[:2] + '-' + puzzle_word[3:] if puzzle_word[3] == guess_word[3] : new_guess_word = new_guess_word[:3] + '-' + new_guess_word[4:] correct = correct[:3] + guess_word[3] + correct[4:] new_puzzle_word = new_puzzle_word[:3] + '-' + puzzle_word[4:] if puzzle_word[4] == guess_word[4] : new_guess_word = new_guess_word[:4] + '-' + new_guess_word[5:] correct = correct[:4] + guess_word[4] + correct[5:] new_puzzle_word = new_puzzle_word[:4] + '-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0]: wrong_position=guess_word[0]+wrong_position[1:] n=position_in_word(guess_word[0],puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word,n,'-') if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: wrong_position=wrong_position[0]+guess_word[1]+wrong_position[2:] n=position_in_word(guess_word[1],puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word,n,'-') if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: wrong_position=wrong_position[:2]+guess_word[2]+wrong_position[3:] n=position_in_word(guess_word[2],puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word,n,'-') if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: wrong_position=wrong_position[:3]+guess_word[3]+wrong_position[4:] n=position_in_word(guess_word[3],puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word,n,'-') if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: wrong_position=wrong_position[:4]+guess_word[4] n=position_in_word(guess_word[4],puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word,n,'-') return wrong_position def replace_kth_letter_in_str(original_str, k, ch): new_str = original_str if k==0 : new_str = ch + new_str[1:] elif k==1 : new_str = new_str[0] + ch +new_str[2:] elif k==2 : new_str = new_str[:2] + ch +new_str[3:] elif k==3 : new_str = new_str[:3] + ch +new_str[4:] elif k==4 : new_str = new_str[:4] + ch return new_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' t1,t2,t3,t4,t5 = text[0],text[1],text[2],text[3],text[4] if t1 != '?' and t1 != '*' : if color == 'yellow': t1 = white_on_yellow + t1 + normal elif color == 'green': t1 = white_on_green + t1 + normal else : t1 = text[0] if t2 != '?' and t2 != '*' : if color == 'yellow': t2 = white_on_yellow + text[1] + normal elif color == 'green': t2 = white_on_green + text[1] + normal else : t2 = text[1] if t3 != '?' and t3 != '*' : if color == 'yellow': t3 = white_on_yellow + text[2] + normal elif color == 'green': t3 = white_on_green + text[2] + normal else : t3 = text[2] if t4 != '?' and t4 != '*' : if color == 'yellow': t4 = white_on_yellow + text[3] + normal elif color == 'green': t4 = white_on_green + text[3] + normal else : t4 = text[3] if t5 != '?' and t5 != '*' : if color == 'yellow': t5 = white_on_yellow + text[4] + normal elif color == 'green': t5 = white_on_green + text[4] + normal else : t5 = text[4] colored_text = t1+t2+t3+t4+t5 return colored_text# 6430222521 sim = 70.91% import random import string def position_in_word(ch, word): if ch in word[0]: position=0 elif ch in word[1]: position=1 elif ch in word[2]: position=2 elif ch in word[3]: position=3 elif ch in word[4]: position=4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if guess_word[0] in puzzle_word[0] : new_guess_word = '-' + new_guess_word[1:] correct = puzzle_word[0]+'????' new_puzzle_word = '-'+puzzle_word[1:] if guess_word[1] in puzzle_word[1] : new_guess_word = new_guess_word[0]+'-'+new_guess_word[2:] correct = correct[0]+puzzle_word[1]+correct[2:] new_puzzle_word = new_puzzle_word[0]+'-'+puzzle_word[2:] if guess_word[2] in puzzle_word[2] : new_guess_word = new_guess_word[:2]+'-'+new_guess_word[3:] correct = correct[:2]+puzzle_word[2]+correct[3:] new_puzzle_word = new_puzzle_word[:2]+'-'+puzzle_word[3:] if guess_word[3] in puzzle_word[3] : new_guess_word = new_guess_word[:3]+'-'+new_guess_word[4:] correct = correct[:3]+puzzle_word[3]+correct[4:] new_puzzle_word = new_puzzle_word[:3]+'-'+puzzle_word[4:] if guess_word[4] in puzzle_word[4] : new_guess_word = new_guess_word[:4]+'-' correct = correct[:4]+puzzle_word[4] new_puzzle_word = new_puzzle_word[:4]+'-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): if guess_word[0] in puzzle_word and guess_word[0] != '-' and guess_word[0] != puzzle_word[0]: ch1 = guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'ก') else : ch1 = '*' if guess_word[1] in puzzle_word and guess_word[1] != '-' and guess_word[1] != puzzle_word[1]: ch2 = guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),'ข') else : ch2 = '*' if guess_word[2] in puzzle_word and guess_word[2] != '-' and guess_word[2] != puzzle_word[2]: ch3 = guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2],puzzle_word),'ค') else : ch3 = '*' if guess_word[3] in puzzle_word and guess_word[3] != '-' and guess_word[3] != puzzle_word[3]: ch4 = guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3],puzzle_word),'ง') else : ch4 = '*' if guess_word[4] in puzzle_word and guess_word[4] != '-' and guess_word[4] != puzzle_word[4]: ch5 = guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[4],puzzle_word),'จ') else : ch5 = '*' wrong_position = ch1+ch2+ch3+ch4+ch5 return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0 : original_str = ch+original_str[1:] if k == 1 : original_str = original_str[0]+ch+original_str[2:] if k == 2 : original_str = original_str[:2]+ch+original_str[3:] if k == 3 : original_str = original_str[:3]+ch+original_str[4:] if k == 4 : original_str = original_str[:4]+ch+original_str[5:] return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == 'green' : if not text[0] in '*?' : ch1 = white_on_green+text[0]+normal else : ch1 = text[0] if not text[1] in '*?' : ch2 = white_on_green+text[1]+normal else : ch2 = text[1] if not text[2] in '*?' : ch3 = white_on_green+text[2]+normal else : ch3 = text[2] if not text[3] in '*?' : ch4 = white_on_green+text[3]+normal else : ch4 = text[3] if not text[4] in '*?' : ch5 = white_on_green+text[4]+normal else : ch5 = text[4] if color == 'yellow' : if not text[0] in '*?' : ch1 = white_on_yellow+text[0]+normal else : ch1 = text[0] if not text[1] in '*?' : ch2 = white_on_yellow+text[1]+normal else : ch2 = text[1] if not text[2] in '*?' : ch3 = white_on_yellow+text[2]+normal else : ch3 = text[2] if not text[3] in '*?' : ch4 = white_on_yellow+text[3]+normal else : ch4 = text[3] if not text[4] in '*?' : ch5 = white_on_yellow+text[4]+normal else : ch5 = text[4] text = ch1+ch2+ch3+ch4+ch5 return text# 6430269021 sim = 70.91% import random import string def position_in_word(ch, word): if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' if puzzle_word[0] == guess_word[0] : correct = guess_word[0] + correct[1:] guess_word = '-' + guess_word[1:] puzzle_word = '-' + puzzle_word[1:] if puzzle_word[1] == guess_word[1] : correct = correct[0] + guess_word[1] + correct[2:] guess_word = guess_word[0] + '-' + guess_word[2:] puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] if puzzle_word[2] == guess_word[2] : correct = correct[:2] + guess_word[2] + correct[3:] guess_word = guess_word[:2] + '-' + guess_word[3:] puzzle_word = puzzle_word[:2] + '-' + puzzle_word[3:] if puzzle_word[3] == guess_word[3] : correct = correct[:3] + guess_word[3] + correct[4:] guess_word = guess_word[:3] + '-' + guess_word[4:] puzzle_word = puzzle_word[:3] + '-' + puzzle_word[4:] if puzzle_word[4] == guess_word[4] : correct = correct[:4] + guess_word[4] + correct[5:] guess_word = guess_word[:4] + '-' + guess_word[5:] puzzle_word = puzzle_word[:4] + '-' + puzzle_word[5:] new_guess_word = guess_word new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' alpha = 'QWERTYUIOPASDFGHJKLZXCVBNM' if guess_word[0] not in alpha : guess_word = '*' + guess_word[1:] if guess_word[1] not in alpha : guess_word = guess_word[0] + '*' + guess_word[2:] if guess_word[2] not in alpha : guess_word = guess_word[:2] + '*' + guess_word[3:] if guess_word[3] not in alpha : guess_word = guess_word[:3] + '*' + guess_word[4] if guess_word[4] not in alpha : guess_word = guess_word[:4] + '*' if guess_word[0] in puzzle_word and guess_word[0] != '-' : wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0],puzzle_word), '$') if guess_word[1] in puzzle_word and guess_word[1] != '-' : wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1],puzzle_word), '$') if guess_word[2] in puzzle_word and guess_word[2] != '-' : wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2],puzzle_word), '$') if guess_word[3] in puzzle_word and guess_word[1] != '-' : wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3],puzzle_word), '$') if guess_word[4] in puzzle_word and guess_word[1] != '-' : wrong_position = wrong_position[:4] + guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4],puzzle_word), '$') return wrong_position def replace_kth_letter_in_str(original_str, k, ch): newstr = original_str if k == 0 : newstr = ch + newstr[1:] if k == 1 : newstr = newstr[0] + ch + newstr[2:] if k == 2 : newstr = newstr[:2] + ch + newstr[3:] if k == 3 : newstr = newstr[:3] + ch + newstr[4:] if k == 4 : newstr = newstr[:4] + ch return newstr def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' alpha = 'QWERTYUIOPASDFGHJKLZXCVBNM' if color == 'green' : if text[0] in alpha : x0 = white_on_green + text[0] + normal else : x0 = text[0] if text[1] in alpha : x1 = white_on_green + text[1] + normal else : x1 = text[1] if text[2] in alpha : x2 = white_on_green + text[2] + normal else : x2 = text[2] if text[3] in alpha : x3 = white_on_green + text[3] + normal else : x3 = text[3] if text[4] in alpha : x4 = white_on_green + text[4] + normal else : x4 = text[4] if color == 'yellow' : if text[0] in alpha : x0 = white_on_yellow + text[0] + normal else : x0 = text[0] if text[1] in alpha : x1 = white_on_yellow + text[1] + normal else : x1 = text[1] if text[2] in alpha : x2 = white_on_yellow + text[2] + normal else : x2 = text[2] if text[3] in alpha : x3 = white_on_yellow + text[3] + normal else : x3 = text[3] if text[4] in alpha : x4 = white_on_yellow + text[4] + normal else : x4 = text[4] text = x0+x1+x2+x3+x4 colored_text = text return colored_text# 6430246621 sim = 70.64% import random import string def position_in_word(ch, word): if word[0]==ch: position=0 elif word[1]==ch: position=1 elif word[2]==ch: position=2 elif word[3]==ch: position=3 elif word[4]==ch: position=4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = '' correct = '' new_puzzle_word = '' if guess_word[0]==puzzle_word[0]: new_guess_word+='-' correct+=puzzle_word[0] new_puzzle_word+='-' else: new_guess_word+=guess_word[0] correct+="?" new_puzzle_word+=puzzle_word[0] if guess_word[1]==puzzle_word[1]: new_guess_word+='-' correct+=puzzle_word[1] new_puzzle_word+='-' else: new_guess_word+=guess_word[1] correct+="?" new_puzzle_word+=puzzle_word[1] if guess_word[2]==puzzle_word[2]: new_guess_word+='-' correct+=puzzle_word[2] new_puzzle_word+='-' else: new_guess_word+=guess_word[2] correct+="?" new_puzzle_word+=puzzle_word[2] if guess_word[3]==puzzle_word[3]: new_guess_word+='-' correct+=puzzle_word[3] new_puzzle_word+='-' else: new_guess_word+=guess_word[3] correct+="?" new_puzzle_word+=puzzle_word[3] if guess_word[4]==puzzle_word[4]: new_guess_word+='-' correct+=puzzle_word[4] new_puzzle_word+='-' else: new_guess_word+=guess_word[4] correct+="?" new_puzzle_word+=puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and 'A'<=guess_word[0]<='z' : wrong_position+=guess_word[0] index=position_in_word(guess_word[0], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, index,'-') else: wrong_position+='*' if guess_word[1] in puzzle_word and 'A'<=guess_word[1]<='z': wrong_position+=guess_word[1] index=position_in_word(guess_word[1], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, index,'-') else: wrong_position+='*' if guess_word[2] in puzzle_word and 'A'<=guess_word[2]<='z': wrong_position+=guess_word[2] index=position_in_word(guess_word[2], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, index,'-') else: wrong_position+='*' if guess_word[3] in puzzle_word and 'A'<=guess_word[3]<='z': wrong_position+=guess_word[3] index=position_in_word(guess_word[3], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, index,'-') else: wrong_position+='*' if guess_word[4] in puzzle_word and 'A'<=guess_word[4]<='z': wrong_position+=guess_word[4] index=position_in_word(guess_word[4], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, index,'-') else: wrong_position+='*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): new_str=original_str[:k]+'-'+original_str[k+1:] return new_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text='' if not ('A'<=text[0]<='Z'): colored_text += text[0] else: if color=='green': colored_text+=white_on_green+text[0]+normal else: colored_text+=white_on_yellow+text[0]+normal if not ('A'<=text[1]<='Z'): colored_text += text[1] else: if color=='green': colored_text+=white_on_green+text[1]+normal else: colored_text+=white_on_yellow+text[1]+normal if not ('A'<=text[2]<='Z'): colored_text += text[2] else: if color=='green': colored_text+=white_on_green+text[2]+normal else: colored_text+=white_on_yellow+text[2]+normal if not ('A'<=text[3]<='Z'): colored_text += text[3] else: if color=='green': colored_text+=white_on_green+text[3]+normal else: colored_text+=white_on_yellow+text[3]+normal if not ('A'<=text[4]<='Z'): colored_text += text[4] else: if color=='green': colored_text+=white_on_green+text[4]+normal else: colored_text+=white_on_yellow+text[4]+normal return colored_text# 6231220221 sim = 70.6% import random import string def position_in_word(ch, word): if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = '' if guess_word[0] == puzzle_word[0]: correct += guess_word[0] guess_word = '-'+guess_word[1:] puzzle_word = '-'+puzzle_word[1:] else: correct += '?' if guess_word[1] == puzzle_word[1]: correct += guess_word[1] guess_word = guess_word[:1]+'-'+guess_word[2:] puzzle_word = puzzle_word[:1]+'-'+puzzle_word[2:] else: correct += '?' if guess_word[2] == puzzle_word[2]: correct += guess_word[2] guess_word = guess_word[:2]+'-'+guess_word[3:] puzzle_word = puzzle_word[:2]+'-'+puzzle_word[3:] else: correct += '?' if guess_word[3] == puzzle_word[3]: correct += guess_word[3] guess_word = guess_word[:3]+'-'+guess_word[4:] puzzle_word = puzzle_word[:3]+'-'+puzzle_word[4:] else: correct += '?' if guess_word[4] == puzzle_word[4]: correct += guess_word[4] guess_word = guess_word[:4]+'-' puzzle_word = puzzle_word[:4]+'-' else: correct += '?' new_guess_word = guess_word new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] == '-': wrong_position += '*' else: if guess_word[0] in puzzle_word: wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'+') else: wrong_position += '*' if guess_word[1] == '-': wrong_position += '*' else: if guess_word[1] in puzzle_word: wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),'+') else: wrong_position += '*' if guess_word[2] == '-': wrong_position += '*' else: if guess_word[2] in puzzle_word: wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2],puzzle_word),'+') else: wrong_position += '*' if guess_word[3] == '-': wrong_position += '*' else: if guess_word[3] in puzzle_word: wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3],puzzle_word),'+') else: wrong_position += '*' if guess_word[4] == '-': wrong_position += '*' else: if guess_word[4] in puzzle_word: wrong_position += guess_word[4] else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): new_str = original_str[:k]+ch+original_str[k+1:] return '' def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' coll = [] if 'A'<=text[0]<='Z': if color == 'green': coll += [white_on_green+text[0]+normal] elif color == 'yellow': coll += [white_on_yellow+text[0]+normal] else: coll += [text[0]] if 'A'<=text[1]<='Z': if color == 'green': coll += [white_on_green+text[1]+normal] elif color == 'yellow': coll += [white_on_yellow+text[1]+normal] else: coll += [text[1]] if 'A'<=text[2]<='Z': if color == 'green': coll += [white_on_green+text[2]+normal] elif color == 'yellow': coll += [white_on_yellow+text[2]+normal] else: coll += [text[2]] if 'A'<=text[3]<='Z': if color == 'green': coll += [white_on_green+text[3]+normal] elif color == 'yellow': coll += [white_on_yellow+text[3]+normal] else: coll += [text[3]] if 'A'<=text[4]<='Z': if color == 'green': coll += [white_on_green+text[4]+normal] elif color == 'yellow': coll += [white_on_yellow+text[4]+normal] else: coll += [text[4]] text = ''.join(coll) colored_text = text return colored_text# 6432104521 sim = 70.54% import random import string def position_in_word(ch, word): if word[0] == ch : a = 0 elif word[1] == ch : a= 1 elif word[2] == ch : a = 2 elif word[3] == ch : a = 3 elif word[4] == ch : a = 4 else : a= -1 return a def check_correct_position(puzzle_word, guess_word): a = '' b = '' c = '' if puzzle_word[0] == guess_word[0] : a = a + '-' b = b + puzzle_word[0] c = c + '-' else : a = a + 'X' b = b + '?' c = c + puzzle_word[0] if puzzle_word[1] == guess_word[1] : a = a + '-' b = b + puzzle_word[1] c = c + '-' else : a = a + 'X' b = b + '?' c = c + puzzle_word[1] if puzzle_word[2] == guess_word[2] : a = a + '-' b = b + puzzle_word[2] c = c + '-' else : a = a + 'X' b = b + '?' c = c + puzzle_word[2] if puzzle_word[3] == guess_word[3] : a = a + '-' b = b + puzzle_word[3] c = c + '-' else : a = a + 'X' b = b + '?' c = c + puzzle_word[3] if puzzle_word[4] == guess_word[4] : a = a + '-' b = b + puzzle_word[4] c = c + '-' else : a = a + 'X' b = b + '?' c = c + puzzle_word[4] return a,b,c def check_wrong_position(puzzle_word, guess_word): a = list(puzzle_word) b = '' if guess_word[0] in a and guess_word[0] != '-' : b = b + guess_word[0] a.remove(guess_word[0]) else : b = b + '*' if guess_word[1] in a and guess_word[1] != '-': b = b + guess_word[1] a.remove(guess_word[1]) else : b = b + '*' if guess_word[2] in a and guess_word[2] != '-' : b = b + guess_word[2] a.remove(guess_word[2]) else : b = b + '*' if guess_word[3] in a and guess_word[3] != '-' : b = b + guess_word[3] a.remove(guess_word[3]) else : b = b + '*' if guess_word[4] in a and guess_word[4] != '-' : b = b + guess_word[4] a.remove(guess_word[4]) else : b = b + '*' return b def replace_kth_letter_in_str(original_str, k, ch): p = original_str[0:k] + ch + original_str[k+1:5] return p def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if ord(text[0]) > 64 and ord(text[0]) < 91 : if color == 'green' : ch1 = white_on_green + text[0] + normal elif color == 'yellow' : ch1 = white_on_yellow + text[0] + normal else : ch1 = text[0] if ord(text[1]) > 64 and ord(text[1]) < 91 : if color == 'green' : ch2 = white_on_green + text[1] + normal elif color == 'yellow' : ch2 = white_on_yellow + text[1] + normal else : ch2 = text[1] if ord(text[2]) > 64 and ord(text[2]) < 91 : if color == 'green' : ch3 = white_on_green + text[2] + normal elif color == 'yellow' : ch3 = white_on_yellow + text[2] + normal else : ch3 = text[2] if ord(text[3]) > 64 and ord(text[3]) < 91 : if color == 'green' : ch4 = white_on_green + text[3] + normal elif color == 'yellow' : ch4 = white_on_yellow + text[3] + normal else : ch4 = text[3] if ord(text[4]) > 64 and ord(text[4]) < 91 : if color == 'green' : ch5 = white_on_green + text[4] + normal elif color == 'yellow' : ch5 = white_on_yellow + text[4] + normal else : ch5 = text[4] colored_text = ch1 + ch2 + ch3 + ch4 + ch5 return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #3(2)

# 6430268421 sim = 92.39% import random import string def position_in_word(ch, word): position = -1 if ch in word[0] : position = 0 if ch in word[1] : position = 1 if ch in word[2] : position = 2 if ch in word[3] : position = 3 if ch in word[4] : position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_guess_word = guess_word new_puzzle_word = puzzle_word if puzzle_word[0] in guess_word[0] : new_guess_word = '-' + new_guess_word[1:] correct = puzzle_word[0] + correct[1:] new_puzzle_word = '-' + puzzle_word[1:] if puzzle_word[1] in guess_word[1] : new_guess_word = new_guess_word[0] +'-' + new_guess_word[2:] correct = correct[0] + puzzle_word[1] + correct[2:] new_puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] if puzzle_word[2] in guess_word[2] : new_guess_word = new_guess_word[:2] + '-' + new_guess_word[3:] correct = correct[:2] + puzzle_word[2] + correct[3:] new_puzzle_word = puzzle_word[:2] + '-' + puzzle_word[3:] if puzzle_word[3] in guess_word[3] : new_guess_word = new_guess_word[:3] + '-' + new_guess_word[-1] correct = correct[:3] + puzzle_word[3] + correct[-1] new_puzzle_word = puzzle_word[:3] + '-' + puzzle_word[-1] if puzzle_word[4] in guess_word[4] : new_guess_word = new_guess_word[:4] + '-' correct = correct[:4] + puzzle_word[4] new_puzzle_word = puzzle_word[:4] + '-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' pwl = [puzzle_word[0],puzzle_word[1],puzzle_word[2],puzzle_word[3],puzzle_word[4]] if guess_word[0] == puzzle_word[0] : pwl.remove(guess_word[0]) if guess_word[1] == puzzle_word[1] : pwl.remove(guess_word[1]) if guess_word[2] == puzzle_word[2] : pwl.remove(guess_word[2]) if guess_word[3] == puzzle_word[3] : pwl.remove(guess_word[3]) if guess_word[4] == puzzle_word[4] : pwl.remove(guess_word[4]) if guess_word[0] in pwl and guess_word[0] != puzzle_word[0]: wrong_position += guess_word[0] pwl.remove(guess_word[0]) else : wrong_position += '*' if guess_word[1] in pwl and guess_word[1] != puzzle_word[1] : wrong_position += guess_word[1] pwl.remove(guess_word[1]) else : wrong_position += '*' if guess_word[2] in pwl and guess_word[2] != puzzle_word[2] : wrong_position += guess_word[2] pwl.remove(guess_word[2]) else : wrong_position += '*' if guess_word[3] in pwl and guess_word[3] != puzzle_word[3] : wrong_position += guess_word[3] pwl.remove(guess_word[3]) else : wrong_position += '*' if guess_word[4] in pwl and guess_word[4] != puzzle_word[4]: wrong_position += guess_word[4] pwl.remove(guess_word[4]) else : wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): rep = '' k = int(k) rep += original_str[:k] + ch + original_str[k+1:] return rep def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' clt = '' if color == 'green' : cl = white_on_green if color == 'yellow' : cl = white_on_yellow if text[0] != '*' and text[0] != '?' : clt += cl + text[0] + normal else : if text[0] == '*' : clt += '*' if text[0] == '?' : clt += '?' if text[1] != '*' and text[1] != '?' : clt += cl + text[1] + normal else : if text[1] == '*' : clt += '*' if text[1] == '?' : clt += '?' if text[2] != '*' and text[2] != '?' : clt += cl + text[2] + normal else : if text[2] == '*' : clt += '*' if text[2] == '?' : clt += '?' if text[3] != '*' and text[3] != '?' : clt += cl + text[3] + normal else : if text[3] == '*' : clt += '*' if text[3] == '?' : clt += '?' if text[4] != '*' and text[4] != '?' : clt += cl + text[4] + normal else : if text[4] == '*' : clt += '*' if text[4] == '?' : clt += '?' colored_text = clt return colored_text# 6430304321 sim = 92.39% import random import string def position_in_word(ch, word): position = -1 if ch in word[0]: position = 0 if ch in word[1]: position = 1 if ch in word[2]: position = 2 if ch in word[3]: position = 3 if ch in word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = 'XXXXX' correct = '?????' new_puzzle_word = puzzle_word if guess_word[0] in puzzle_word[0]: new_guess_word = '-' + new_guess_word[1:] correct = puzzle_word[0] + correct[1:] new_puzzle_word = '-' + puzzle_word[1:] if guess_word[1] in puzzle_word[1]: new_guess_word = new_guess_word[0] + '-' + new_guess_word[2:] correct = correct[0] + puzzle_word[1] + correct[2:] new_puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] if guess_word[2] in puzzle_word[2]: new_guess_word = new_guess_word[:2] + '-' + new_guess_word[3:] correct = correct[:2] + puzzle_word[2] + correct[3:] new_puzzle_word = puzzle_word[:2] + '-' + puzzle_word[3:] if guess_word[3] in puzzle_word[3]: new_guess_word = new_guess_word[:3] + '-' + new_guess_word[4:] correct = correct[:3] + puzzle_word[3] + correct[4:] new_puzzle_word = puzzle_word[:3] + '-' + puzzle_word[4:] if guess_word[4] in puzzle_word[4]: new_guess_word = new_guess_word[:4] + '-' correct = correct[:4] + puzzle_word[4] new_puzzle_word = puzzle_word[:4] + '-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' puzzleword = [puzzle_word[0],puzzle_word[1],puzzle_word[2],puzzle_word[3],puzzle_word[4]] if guess_word[0] == puzzle_word[0]: puzzleword.remove(guess_word[0]) if guess_word[1] == puzzle_word[1]: puzzleword.remove(guess_word[1]) if guess_word[2] == puzzle_word[2]: puzzleword.remove(guess_word[2]) if guess_word[3] == puzzle_word[3]: puzzleword.remove(guess_word[3]) if guess_word[4] == puzzle_word[4]: puzzleword.remove(guess_word[4]) if guess_word[0] in puzzleword and guess_word[0] != puzzle_word[0]: wrong_position += guess_word[0] puzzleword.remove(guess_word[0]) else: wrong_position += '*' if guess_word[1] in puzzleword and guess_word[1] != puzzle_word[1]: wrong_position += guess_word[1] puzzleword.remove(guess_word[1]) else: wrong_position += '*' if guess_word[2] in puzzleword and guess_word[2] != puzzle_word[2]: wrong_position += guess_word[2] puzzleword.remove(guess_word[2]) else: wrong_position += '*' if guess_word[3] in puzzleword and guess_word[3] != puzzle_word[3]: wrong_position += guess_word[3] puzzleword.remove(guess_word[3]) else: wrong_position += '*' if guess_word[4] in puzzleword and guess_word[4] != puzzle_word[4]: wrong_position += guess_word[4] puzzleword.remove(guess_word[4]) else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): replace = '' k = int(k) replace += original_str[:k] + ch + original_str[k+1:] return replace def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colour = '' colour_text = '' if color == 'green': colour = white_on_green if color == 'yellow': colour = white_on_yellow if text[0] != '?' and text[0] != '*': colour_text += colour + text[0] + normal elif text[0] == '?': colour_text += '?' elif text[0] == '*': colour_text += '*' if text[1] != '?' and text[1] != '*': colour_text += colour + text[1] + normal elif text[1] == '?': colour_text += '?' elif text[1] == '*': colour_text += '*' if text[2] != '?' and text[2] != '*': colour_text += colour + text[2] + normal elif text[2] == '?': colour_text += '?' elif text[2] == '*': colour_text += '*' if text[3] != '?' and text[3] != '*': colour_text += colour + text[3] + normal elif text[3] == '?': colour_text += '?' elif text[3] == '*': colour_text += '*' if text[4] != '?' and text[4] != '*': colour_text += colour + text[4] + normal elif text[4] == '?': colour_text += '?' elif text[4] == '*': colour_text += '*' colored_text = colour_text return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #4(48)

# 6430277021 sim = 92.33% import random import string def position_in_word(ch, word): position = -1 if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0] : correct += puzzle_word[0] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') else : correct += '?' if guess_word[1] == puzzle_word[1] : correct += puzzle_word[1] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') else : correct += '?' if guess_word[2] == puzzle_word[2] : correct += puzzle_word[2] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') else : correct += '?' if guess_word[3] == puzzle_word[3] : correct += puzzle_word[3] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') else : correct += '?' if guess_word[4] == puzzle_word[4] : correct += puzzle_word[4] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') else : correct += '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != '-' : wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), '-') else : wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != '-' : wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), '-') else : wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != '-' : wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), '-') else : wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != '-' : wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), '-') else : wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != '-' : wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), '-') else : wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green' : if text[0] != '?' and text[0] != '*' : colored_text += white_on_green + text[0] + normal else : colored_text += text[0] if text[1] != '?' and text[1] != '*' : colored_text += white_on_green + text[1] + normal else : colored_text += text[1] if text[2] != '?' and text[2] != '*' : colored_text += white_on_green + text[2] + normal else : colored_text += text[2] if text[3] != '?' and text[3] != '*' : colored_text += white_on_green + text[3] + normal else : colored_text += text[3] if text[4] != '?' and text[4] != '*' : colored_text += white_on_green + text[4] + normal else : colored_text += text[4] elif color == 'yellow' : if text[0] != '?' and text[0] != '*' : colored_text += white_on_yellow + text[0] + normal else : colored_text += text[0] if text[1] != '?' and text[1] != '*' : colored_text += white_on_yellow + text[1] + normal else : colored_text += text[1] if text[2] != '?' and text[2] != '*' : colored_text += white_on_yellow + text[2] + normal else : colored_text += text[2] if text[3] != '?' and text[3] != '*' : colored_text += white_on_yellow + text[3] + normal else : colored_text += text[3] if text[4] != '?' and text[4] != '*' : colored_text += white_on_yellow + text[4] + normal else : colored_text += text[4] else : return text return colored_text# 6430392521 sim = 92.33% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: correct += guess_word[0] new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') else: correct += '?' if guess_word[1] == puzzle_word[1]: correct += guess_word[1] new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') else: correct += '?' if guess_word[2] == puzzle_word[2]: correct += guess_word[2] new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') else: correct += '?' if guess_word[3] == puzzle_word[3]: correct += guess_word[3] new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') else: correct += '?' if guess_word[4] == puzzle_word[4]: correct += guess_word[4] new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') else: correct += '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): new_str = original_str[:k] + ch + original_str[k+1:] return new_str def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != '-': wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), '-') else: wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != '-': wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), '-') else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != '-': wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), '-') else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != '-': wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), '-') else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != '-': wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), '-') else: wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == 'green': if text[0] != '?' and text[0] != '*': t0 = white_on_green + text[0] + normal else: t0 = text[0] if text[1] != '?' and text[1] != '*': t1 = white_on_green + text[1] + normal else: t1 = text[1] if text[2] != '?' and text[2] != '*': t2 = white_on_green + text[2] + normal else: t2 = text[2] if text[3] != '?' and text[3] != '*': t3 = white_on_green + text[3] + normal else: t3 = text[3] if text[4] != '?' and text[4] != '*': t4 = white_on_green + text[4] + normal else: t4 = text[4] elif color == 'yellow': if text[0] != '?' and text[0] != '*': t0 = white_on_yellow + text[0] + normal else: t0 = text[0] if text[1] != '?' and text[1] != '*': t1 = white_on_yellow + text[1] + normal else: t1 = text[1] if text[2] != '?' and text[2] != '*': t2 = white_on_yellow + text[2] + normal else: t2 = text[2] if text[3] != '?' and text[3] != '*': t3 = white_on_yellow + text[3] + normal else: t3 = text[3] if text[4] != '?' and text[4] != '*': t4 = white_on_yellow + text[4] + normal else: t4 = text[4] colored_text = t0+t1+t2+t3+t4 return colored_text# 6430173421 sim = 89.75% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = "" correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: correct += puzzle_word[0] new_guess_word += "-" new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') else: correct += "?" new_guess_word += guess_word[0] if puzzle_word[1] == guess_word[1]: correct += puzzle_word[1] new_guess_word += "-" new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') else: correct += "?" new_guess_word += guess_word[1] if puzzle_word[2] == guess_word[2]: correct += puzzle_word[2] new_guess_word += "-" new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') else: correct += "?" new_guess_word += guess_word[2] if puzzle_word[3] == guess_word[3]: correct += puzzle_word[3] new_guess_word += "-" new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') else: correct += "?" new_guess_word += guess_word[3] if puzzle_word[4] == guess_word[4]: correct += puzzle_word[4] new_guess_word += "-" new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') else: correct += "?" new_guess_word += guess_word[4] return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and puzzle_word[0] != guess_word[0]: wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0],puzzle_word), '-') else: wrong_position += "*" if guess_word[1] in puzzle_word and puzzle_word[1] != guess_word[1]: wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1],puzzle_word), '-') else: wrong_position += "*" if guess_word[2] in puzzle_word and puzzle_word[2] != guess_word[2]: wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2],puzzle_word), '-') else: wrong_position += "*" if guess_word[3] in puzzle_word and puzzle_word[3] != guess_word[3]: wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3],puzzle_word), '-') else: wrong_position += "*" if guess_word[4] in puzzle_word and puzzle_word[4] != guess_word[4]: wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4],puzzle_word), '-') else: wrong_position += "*" return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = "" if text[0] not in "*?": if color == "yellow": colored_text += white_on_yellow + text[0] + normal if color == "green": colored_text += white_on_green + text[0] + normal else: colored_text += text[0] if text[1] not in "*?": if color == "yellow": colored_text += white_on_yellow + text[1] + normal if color == "green": colored_text += white_on_green + text[1] + normal else: colored_text += text[1] if text[2] not in "*?": if color == "yellow": colored_text += white_on_yellow + text[2] + normal if color == "green": colored_text += white_on_green + text[2] + normal else: colored_text += text[2] if text[3] not in "*?": if color == "yellow": colored_text += white_on_yellow + text[3] + normal if color == "green": colored_text += white_on_green + text[3] + normal else: colored_text += text[3] if text[4] not in "*?": if color == "yellow": colored_text += white_on_yellow + text[4] + normal if color == "green": colored_text += white_on_green + text[4] + normal else: colored_text += text[4] return colored_text# 6432050221 sim = 89.75% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = '' correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: correct += guess_word[0] new_guess_word += '-' new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,0,'-') else: correct += '?' new_guess_word += guess_word[0] if puzzle_word[1] == guess_word[1]: correct += guess_word[1] new_guess_word += '-' new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,1,'-') else: correct += '?' new_guess_word += guess_word[1] if puzzle_word[2] == guess_word[2]: correct += guess_word[2] new_guess_word += '-' new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,2,'-') else: correct += '?' new_guess_word += guess_word[2] if puzzle_word[3] == guess_word[3]: correct += guess_word[3] new_guess_word += '-' new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,3,'-') else: correct += '?' new_guess_word += guess_word[3] if puzzle_word[4] == guess_word[4]: correct += guess_word[4] new_guess_word += '-' new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,4,'-') else: correct += '?' new_guess_word += guess_word[4] return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0]: wrong_position += guess_word[0] puzzle_word == replace_kth_letter_in_str(puzzle_word,0,'-') else: wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: wrong_position += guess_word[1] puzzle_word == replace_kth_letter_in_str(puzzle_word,1,'-') else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: wrong_position += guess_word[2] puzzle_word == replace_kth_letter_in_str(puzzle_word,2,'-') else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: wrong_position += guess_word[3] puzzle_word == replace_kth_letter_in_str(puzzle_word,3,'-') else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: wrong_position += guess_word[4] puzzle_word == replace_kth_letter_in_str(puzzle_word,4,'-') else: wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text[0] not in '?*': if color == 'yellow': colored_text += white_on_yellow + text[0] + normal if color == 'green': colored_text += white_on_green + text[0] + normal else: colored_text += text[0] if text[1] not in '?*': if color == 'yellow': colored_text += white_on_yellow + text[1] + normal if color == 'green': colored_text += white_on_green + text[1] + normal else: colored_text += text[1] if text[2] not in '?*': if color == 'yellow': colored_text += white_on_yellow + text[2] + normal if color == 'green': colored_text += white_on_green + text[2] + normal else: colored_text += text[2] if text[3] not in '?*': if color == 'yellow': colored_text += white_on_yellow + text[3] + normal if color == 'green': colored_text += white_on_green + text[3] + normal else: colored_text += text[3] if text[4] not in '?*': if color == 'yellow': colored_text += white_on_yellow + text[4] + normal if color == 'green': colored_text += white_on_green + text[4] + normal else: colored_text += text[4] return colored_text# 6430451921 sim = 89.28% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_guess_word = replace_kth_letter_in_str(guess_word, 0, "-") correct = replace_kth_letter_in_str(correct, 0, guess_word[0]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, "-") if guess_word[1] == puzzle_word[1]: new_guess_word = replace_kth_letter_in_str(guess_word, 1, "-") correct = replace_kth_letter_in_str(correct, 1, guess_word[1]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, "-") if guess_word[2] == puzzle_word[2]: new_guess_word = replace_kth_letter_in_str(guess_word, 2, "-") correct = replace_kth_letter_in_str(correct, 2, guess_word[2]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, "-") if guess_word[3] == puzzle_word[3]: new_guess_word = replace_kth_letter_in_str(guess_word, 3, "-") correct = replace_kth_letter_in_str(correct, 3, guess_word[3]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, "-") if guess_word[4] == puzzle_word[4]: new_guess_word = replace_kth_letter_in_str(guess_word, 4, "-") correct = replace_kth_letter_in_str(correct, 4, guess_word[4]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, "-") return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): if k == 0: rp = ch + original_str[1::] elif k == 4: rp = original_str[0:k:] + ch else : rp = original_str[0:k:] + ch + original_str[k+1::] return rp def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] != puzzle_word[0] and guess_word[0] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 0, guess_word[0]) a = position_in_word(guess_word[0], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, a, '-') if guess_word[1] != puzzle_word[1] and guess_word[1] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 1, guess_word[1]) a = position_in_word(guess_word[1], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, a, '-') if guess_word[2] != puzzle_word[2] and guess_word[2] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 2, guess_word[2]) a = position_in_word(guess_word[2], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, a, '-') if guess_word[3] != puzzle_word[3] and guess_word[3] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 3, guess_word[3]) a = position_in_word(guess_word[3], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, a, '-') if guess_word[4] != puzzle_word[4] and guess_word[4] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 4, guess_word[4]) a = position_in_word(guess_word[4], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, a, '-') return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == 'green': if 'A' <= text[0] <= 'Z': b1 = white_on_green + text[0] + normal else : b1 = text[0] if 'A' <= text[1] <= 'Z': b2 = white_on_green + text[1] + normal else : b2 = text[1] if 'A' <= text[2] <= 'Z': b3 = white_on_green + text[2] + normal else : b3 = text[2] if 'A' <= text[3] <= 'Z': b4 = white_on_green + text[3] + normal else : b4 = text[3] if 'A' <= text[4] <= 'Z': b5 = white_on_green + text[4] + normal else : b5 = text[4] if color == 'yellow': if 'A' <= text[0] <= 'Z': b1 = white_on_yellow + text[0] + normal else : b1 = text[0] if 'A' <= text[1] <= 'Z': b2 = white_on_yellow + text[1] + normal else : b2 = text[1] if 'A' <= text[2] <= 'Z': b3 = white_on_yellow + text[2] + normal else : b3 = text[2] if 'A' <= text[3] <= 'Z': b4 = white_on_yellow + text[3] + normal else : b4 = text[3] if 'A' <= text[4] <= 'Z': b5 = white_on_yellow + text[4] + normal else : b5 = text[4] colored_text = b1 + b2 + b3 + b4 + b5 return colored_text# 6432009621 sim = 89.28% import random import string def position_in_word(ch, word): position = -1 if ch==word[0]: position=0 elif ch==word[1]: position=1 elif ch==word[2]: position=2 elif ch==word[3]: position=3 elif ch==word[4]: position=4 else: position=-1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = "?????" new_puzzle_word = puzzle_word if guess_word[0]==puzzle_word[0]: new_guess_word=replace_kth_letter_in_str(new_guess_word, 0, "-") correct=replace_kth_letter_in_str(correct, 0, guess_word[0]) new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 0, "-") if guess_word[1]==puzzle_word[1]: new_guess_word=replace_kth_letter_in_str(new_guess_word, 1, "-") correct=replace_kth_letter_in_str(correct, 1, guess_word[1]) new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 1, "-") if guess_word[2]==puzzle_word[2]: new_guess_word=replace_kth_letter_in_str(new_guess_word, 2, "-") correct=replace_kth_letter_in_str(correct, 2, guess_word[2]) new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 2, "-") if guess_word[3]==puzzle_word[3]: new_guess_word=replace_kth_letter_in_str(new_guess_word, 3, "-") correct=replace_kth_letter_in_str(correct, 3, guess_word[3]) new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 3, "-") if guess_word[4]==puzzle_word[4]: new_guess_word=replace_kth_letter_in_str(new_guess_word, 4, "-") correct=replace_kth_letter_in_str(correct, 4, guess_word[4]) new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 4, "-") return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): s_str=original_str if k==0: s_str=ch+original_str[1::] elif k==1: s_str=original_str[0]+ch+original_str[2::] elif k==2: s_str=original_str[0:2]+ch+original_str[3::] elif k==3: s_str=original_str[0:3]+ch+original_str[4] elif k==4: s_str=original_str[0:4]+ch return s_str def check_wrong_position(puzzle_word, guess_word): wrong_position = "*****" if guess_word[0]!=puzzle_word[0] and guess_word[0] in puzzle_word: wrong_position=replace_kth_letter_in_str(wrong_position, 0, guess_word[0]) x=position_in_word(guess_word[0], puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word, x, "-") if guess_word[1]!=puzzle_word[1] and guess_word[1] in puzzle_word: wrong_position=replace_kth_letter_in_str(wrong_position, 1, guess_word[1]) x=position_in_word(guess_word[1], puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word, x, "-") if guess_word[2]!=puzzle_word[2] and guess_word[2] in puzzle_word: wrong_position=replace_kth_letter_in_str(wrong_position, 2, guess_word[2]) x=position_in_word(guess_word[2], puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word, x, "-") if guess_word[3]!=puzzle_word[3] and guess_word[3] in puzzle_word: wrong_position=replace_kth_letter_in_str(wrong_position, 3, guess_word[3]) x=position_in_word(guess_word[3], puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word, x, "-") if guess_word[4]!=puzzle_word[4] and guess_word[4] in puzzle_word: wrong_position=replace_kth_letter_in_str(wrong_position, 4, guess_word[4]) x=position_in_word(guess_word[4], puzzle_word) puzzle_word=replace_kth_letter_in_str(puzzle_word, x, "-") return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text="" if color=="green": if "A"<=text[0]<="Z": ch1=white_on_green + text[0] + normal else: ch1=text[0] colored_text+=ch1 if "A"<=text[1]<="Z": ch2=white_on_green + text[1] + normal else: ch2=text[1] colored_text+=ch2 if "A"<=text[2]<="Z": ch3=white_on_green + text[2] + normal else: ch3=text[2] colored_text+=ch3 if "A"<=text[3]<="Z": ch4=white_on_green + text[3] + normal else: ch4=text[3] colored_text+=ch4 if "A"<=text[4]<="Z": ch5=white_on_green + text[4] + normal else: ch5=text[4] colored_text+=ch5 if color=="yellow": if "A"<=text[0]<="Z": ch1=white_on_yellow + text[0] + normal else: ch1=text[0] colored_text+=ch1 if "A"<=text[1]<="Z": ch2=white_on_yellow + text[1] + normal else: ch2=text[1] colored_text+=ch2 if "A"<=text[2]<="Z": ch3=white_on_yellow + text[2] + normal else: ch3=text[2] colored_text+=ch3 if "A"<=text[3]<="Z": ch4=white_on_yellow + text[3] + normal else: ch4=text[3] colored_text+=ch4 if "A"<=text[4]<="Z": ch5=white_on_yellow + text[4] + normal else: ch5=text[4] colored_text+=ch5 return colored_text# 6430343821 sim = 88.5% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 else: position = -1 if word[1] == ch: position = 1 else: position = -1 if word[2] == ch: position = 2 else: position = -1 if word[3] == ch: position = 3 else: position = -1 if word[4] == ch: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, "-") correct += puzzle_word[0] else: correct += "?" if puzzle_word[1] == guess_word[1]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, "-") correct += puzzle_word[1] else: correct += "?" if puzzle_word[2] == guess_word[2]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, "-") correct += puzzle_word[2] else: correct += "?" if puzzle_word[3] == guess_word[3]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, "-") correct += puzzle_word[3] else: correct += "?" if puzzle_word[4] == guess_word[4]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, "-") correct += puzzle_word[4] else: correct += "?" return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k + 1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' new_puzzle_word = puzzle_word if position_in_word(guess_word[0], new_puzzle_word) != -1 and guess_word[0] != "-": wrong_position += guess_word[0] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[0], new_puzzle_word), "-") else: wrong_position += "*" if position_in_word(guess_word[1], new_puzzle_word) != -1 and guess_word[1] != "-": wrong_position += guess_word[1] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[1], new_puzzle_word), "-") else: wrong_position += "*" if position_in_word(guess_word[2], new_puzzle_word) != -1 and guess_word[2] != "-": wrong_position += guess_word[2] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[2], new_puzzle_word), "-") else: wrong_position += "*" if position_in_word(guess_word[3], new_puzzle_word) != -1 and guess_word[3] != "-": wrong_position += guess_word[3] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[3], new_puzzle_word), "-") else: wrong_position += "*" if position_in_word(guess_word[4], new_puzzle_word) != -1 and guess_word[4] != "-": wrong_position += guess_word[4] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[4], new_puzzle_word), "-") else: wrong_position += "*" return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == "green": color_change = white_on_green else: color_change = '\033[34;43m' colored_text = '' if text[0].isalpha(): colored_text += color_change + text[0] + normal else: colored_text += text[0] if text[1].isalpha(): colored_text += color_change + text[1] + normal else: colored_text += text[1] if text[2].isalpha(): colored_text += color_change + text[2] + normal else: colored_text += text[2] if text[3].isalpha(): colored_text += color_change + text[3] + normal else: colored_text += text[3] if text[4].isalpha(): colored_text += color_change + text[4] + normal else: colored_text += text[4] return colored_text# 6432097821 sim = 88.5% import random import string def position_in_word(ch, word): position = -1 if word[0]==ch: position=0 elif word[1]==ch: position=1 elif word[2]==ch: position=2 elif word[3]==ch: position=3 elif word[4]==ch: position=4 return position return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, "-") correct += puzzle_word[0] else: correct += "?" if puzzle_word[1] == guess_word[1]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, "-") correct += puzzle_word[1] else: correct += "?" if puzzle_word[2] == guess_word[2]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, "-") correct += puzzle_word[2] else: correct += "?" if puzzle_word[3] == guess_word[3]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, "-") correct += puzzle_word[3] else: correct += "?" if puzzle_word[4] == guess_word[4]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, "-") correct += puzzle_word[4] else: correct += "?" return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k + 1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' new_puzzle_word=puzzle_word if position_in_word(guess_word[0], new_puzzle_word) != -1 and guess_word[0] != "-": wrong_position += guess_word[0] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[0], new_puzzle_word), "-") else: wrong_position += "*" if position_in_word(guess_word[1], new_puzzle_word) != -1 and guess_word[1] != "-": wrong_position += guess_word[1] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[1], new_puzzle_word), "-") else: wrong_position += "*" if position_in_word(guess_word[2], new_puzzle_word) != -1 and guess_word[2] != "-": wrong_position += guess_word[2] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[2], new_puzzle_word), "-") else: wrong_position += "*" if position_in_word(guess_word[3], new_puzzle_word) != -1 and guess_word[3] != "-": wrong_position += guess_word[3] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[3], new_puzzle_word), "-") else: wrong_position += "*" if position_in_word(guess_word[4], new_puzzle_word) != -1 and guess_word[4] != "-": wrong_position += guess_word[4] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[4], new_puzzle_word), "-") else: wrong_position += "*" return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == "green": background = white_on_green elif color=="yellow": background = white_on_yellow colored_text = '' if not ("?" in text[0] or "*" in text[0]): colored_text += background + text[0] + normal else: colored_text += text[0] if not ("?" in text[1] or "*" in text[1]): colored_text += background + text[1] + normal else: colored_text += text[1] if not ("?" in text[2] or "*" in text[2]): colored_text += background + text[2] + normal else: colored_text += text[2] if not ("?" in text[3] or "*" in text[3]): colored_text += background + text[3] + normal else: colored_text += text[3] if not ("?" in text[4] or "*" in text[4]): colored_text += background + text[4] + normal else: colored_text += text[4] return colored_text# 6430199821 sim = 88.48% import random import string def position_in_word(ch, word): position = -1 if ch in word[0]: return 0 elif ch in word[1]: return 1 elif ch in word[2]: return 2 elif ch in word[3]: return 3 elif ch in word[4]: return 4 return position def check_correct_position(puzzle_word, guess_word): correct = "" new_guess_word = "" new_puzzle_word = puzzle_word if guess_word[0] in puzzle_word[0]: correct+= guess_word[0] new_guess_word += "-" new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,0,"-") else: correct += "?" new_guess_word += guess_word[0] if guess_word[1] in puzzle_word[1]: correct+= guess_word[1] new_guess_word += "-" new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,1,"-") else: correct += "?" new_guess_word += guess_word[1] if guess_word[2] in puzzle_word[2]: correct+= guess_word[2] new_guess_word += "-" new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,2,"-") else: correct += "?" new_guess_word += guess_word[2] if guess_word[3] in puzzle_word[3]: correct+= guess_word[3] new_guess_word += "-" new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,3,"-") else: correct += "?" new_guess_word += guess_word[3] if guess_word[4] in puzzle_word[4]: correct+= guess_word[4] new_guess_word += "-" new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,4,"-") else: correct += "?" new_guess_word += guess_word[4] return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[0:k] + ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = "" if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0]: wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),"-") else: wrong_position += "*" if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),"-") else: wrong_position += "*" if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2],puzzle_word),"-") else: wrong_position += "*" if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3],puzzle_word),"-") else: wrong_position += "*" if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[4],puzzle_word),"-") else: wrong_position += "*" return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' text_with_color = "" if text[0] not in ["?","*"]: if color == "yellow": text_with_color += white_on_yellow + text[0] + normal if color == "green": text_with_color += white_on_green + text[0] + normal else: text_with_color += text[0] if text[1] not in ["?","*"]: if color == "yellow": text_with_color += white_on_yellow + text[1] + normal if color == "green": text_with_color += white_on_green + text[1] + normal else: text_with_color += text[1] if text[2] not in ["?","*"]: if color == "yellow": text_with_color += white_on_yellow + text[2] + normal if color == "green": text_with_color += white_on_green + text[2] + normal else: text_with_color += text[2] if text[3] not in ["?","*"]: if color == "yellow": text_with_color += white_on_yellow + text[3] + normal if color == "green": text_with_color += white_on_green + text[3] + normal else: text_with_color += text[3] if text[4] not in ["?","*"]: if color == "yellow": text_with_color += white_on_yellow + text[4] + normal if color == "green": text_with_color += white_on_green + text[4] + normal else: text_with_color += text[4] return text_with_color# 6432103921 sim = 87.43% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, "-") correct += puzzle_word[0] else: correct += "?" if puzzle_word[1] == guess_word[1]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, "-") correct += puzzle_word[1] else: correct += "?" if puzzle_word[2] == guess_word[2]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, "-") correct += puzzle_word[2] else: correct += "?" if puzzle_word[3] == guess_word[3]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, "-") correct += puzzle_word[3] else: correct += "?" if puzzle_word[4] == guess_word[4]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, "-") correct += puzzle_word[4] else: correct += "?" return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k + 1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0]: wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), "-") else: wrong_position += "*" if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), "-") else: wrong_position += "*" if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), "-") else: wrong_position += "*" if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), "-") else: wrong_position += "*" if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), "-") else: wrong_position += "*" return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == "green": color_change = white_on_green else: color_change = '\033[34;43m' colored_text = '' if text[0] not in "*?": if color == 'yellow': colored_text += white_on_yellow + text[0] + normal if color == 'green': colored_text += white_on_green + text[0] + normal else: colored_text += text[0] if text[1] not in "*?": if color == 'yellow': colored_text += white_on_yellow + text[1] + normal if color == 'green': colored_text += white_on_green + text[1] + normal else: colored_text += text[1] if text[2] not in "*?": if color == 'yellow': colored_text += white_on_yellow + text[2] + normal if color == 'green': colored_text += white_on_green + text[2] + normal else: colored_text += text[2] if text[3] not in "*?": if color == 'yellow': colored_text += white_on_yellow + text[3] + normal if color == 'green': colored_text += white_on_green + text[3] + normal else: colored_text += text[3] if text[4] not in "*?": if color == 'yellow': colored_text += white_on_yellow + text[4] + normal if color == 'green': colored_text += white_on_green + text[4] + normal else: colored_text += text[4] return colored_text# 6432200021 sim = 87.43% import random import string def position_in_word(ch, word): position = -1 if word[0]==ch: position=0 elif word[1]==ch: position=1 elif word[2]==ch: position=2 elif word[3]==ch: position=3 elif word[4]==ch: position=4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = "" new_puzzle_word = puzzle_word if puzzle_word[0]==guess_word[0]: correct += guess_word[0] new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, "-") else : correct += "?" if puzzle_word[1]==guess_word[1]: correct += guess_word[1] new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, "-") else : correct += "?" if puzzle_word[2]==guess_word[2]: correct += guess_word[2] new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, "-") else : correct += "?" if puzzle_word[3]==guess_word[3]: correct += guess_word[3] new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, "-") else : correct += "?" if puzzle_word[4]==guess_word[4]: correct += guess_word[4] new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, "-") else : correct += "?" return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[0:k] + ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = "" if guess_word[0] in puzzle_word and guess_word[0]!=puzzle_word[0]: wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), "-") else: wrong_position += "*" if guess_word[1] in puzzle_word and guess_word[1]!=puzzle_word[1]: wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), "-") else: wrong_position += "*" if guess_word[2] in puzzle_word and guess_word[2]!=puzzle_word[2]: wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), "-") else: wrong_position += "*" if guess_word[3] in puzzle_word and guess_word[3]!=puzzle_word[3]: wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), "-") else: wrong_position += "*" if guess_word[4] in puzzle_word and guess_word[4]!=puzzle_word[4]: wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), "-") else: wrong_position += "*" return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = "" if text[0] != "*" and text[0] != "?": if color == "green": colored_text += white_on_green + text[0] + normal if color == "yellow": colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if text[1] != "*" and text[1] != "?": if color == "green": colored_text += white_on_green + text[1] + normal if color == "yellow": colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if text[2] != "*" and text[2] != "?": if color == "green": colored_text += white_on_green + text[2] + normal if color == "yellow": colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if text[3] != "*" and text[3] != "?": if color == "green": colored_text += white_on_green + text[3] + normal if color == "yellow": colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if text[4] != "*" and text[4] != "?": if color == "green": colored_text += white_on_green + text[4] + normal if color == "yellow": colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text# 6432199121 sim = 86.65% import random import string def position_in_word(ch, word): position = -1 if word[4] == ch : position = 4 if word[3] == ch : position = 3 if word[2] == ch : position = 2 if word[1] == ch : position = 1 if word[0] == ch : position = 0 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: correct += guess_word[0] new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') else: correct += '?' if puzzle_word[1] == guess_word[1]: correct += guess_word[1] new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') else: correct += '?' if puzzle_word[2] == guess_word[2]: correct += guess_word[2] new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') else: correct += '?' if puzzle_word[3] == guess_word[3]: correct += guess_word[3] new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') else: correct += '?' if puzzle_word[4] == guess_word[4]: correct += guess_word[4] new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') else: correct += '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): ok = original_str[:k] + ch + original_str[k+1:] return ok def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != '-' : wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word) , 't') else : wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != '-' : wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word) , 't') else : wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != '-' : wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word) , 't') else : wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != '-' : wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word) , 't') else : wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != '-' : wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word) , 't') else : wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if 'A' <= text[0] <= 'Z' : if color == 'green' : t0 = white_on_green + text[0] + normal if color == 'yellow' : t0 = white_on_yellow + text[0] + normal else : t0 = text[0] if 'A' <= text[1] <= 'Z' : if color == 'green' : t1 = white_on_green + text[1] + normal if color == 'yellow' : t1 = white_on_yellow + text[1] + normal else : t1 = text[1] if 'A' <= text[2] <= 'Z' : if color == 'green' : t2 = white_on_green + text[2] + normal if color == 'yellow' : t2 = white_on_yellow + text[2] + normal else : t2 = text[2] if 'A' <= text[3] <= 'Z' : if color == 'green' : t3 = white_on_green + text[3] + normal if color == 'yellow' : t3 = white_on_yellow + text[3] + normal else : t3 = text[3] if 'A' <= text[4] <= 'Z' : if color == 'green' : t4 = white_on_green + text[4] + normal if color == 'yellow' : t4 = white_on_yellow + text[4] + normal else : t4 = text[4] colored_text = t0+t1+t2+t3+t4 return colored_text# 6432067021 sim = 85.02% import random import string def position_in_word(ch, word): position = -1 if ch in word: if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '' new_puzzle_word = puzzle_word new_guess_word = guess_word if puzzle_word[0] == guess_word[0]: correct += guess_word[0] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') else: correct += '?' if puzzle_word[1] == guess_word[1]: correct += guess_word[1] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') else: correct += '?' if puzzle_word[2] == guess_word[2]: correct += guess_word[2] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') else: correct += '?' if puzzle_word[3] == guess_word[3]: correct += guess_word[3] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') else: correct += '?' if puzzle_word[4] == guess_word[4]: correct += guess_word[4] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') else: correct += '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[0:k] + ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != '-' and puzzle_word[0] != '-': wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), '*') else: wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != '-' and puzzle_word[1] != '-': wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), '*') else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != '-' and puzzle_word[2] != '-': wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), '*') else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != '-' and puzzle_word[3] != '-': wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), '*') else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != '-' and puzzle_word[4] != '-': wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), '*') else: wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green': if text[0] == '?': colored_text += normal else: colored_text += white_on_green colored_text += text[0] if text[1] == '?': colored_text += normal else: colored_text += white_on_green colored_text += text[1] if text[2] == '?': colored_text += normal else: colored_text += white_on_green colored_text += text[2] if text[3] == '?': colored_text += normal else: colored_text += white_on_green colored_text += text[3] if text[4] == '?': colored_text += normal else: colored_text += white_on_green colored_text += text[4] else: if text[0] == '*': colored_text += normal else: colored_text += white_on_yellow colored_text += text[0] if text[1] == '*': colored_text += normal else: colored_text += white_on_yellow colored_text += text[1] if text[2] == '*': colored_text += normal else: colored_text += white_on_yellow colored_text += text[2] if text[3] == '*': colored_text += normal else: colored_text += white_on_yellow colored_text += text[3] if text[4] == '*': colored_text += normal else: colored_text += white_on_yellow colored_text += text[4] colored_text += normal return colored_text# 6432106821 sim = 85.02% import random import string def position_in_word(ch, word): position = -1 if word[0]==ch: position = 0 else: if word[1]==ch: position = 1 else: if word[2]==ch: position = 2 else: if word[3]==ch: position = 3 else: if word[4]==ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '' new_puzzle_word = puzzle_word new_guess_word = guess_word if puzzle_word[0]==guess_word[0]: correct += puzzle_word[0] new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 0, '-') new_guess_word=replace_kth_letter_in_str(new_guess_word, 0, '-') else: correct+='?' if puzzle_word[1]==guess_word[1]: correct += puzzle_word[1] new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 1, '-') new_guess_word=replace_kth_letter_in_str(new_guess_word, 1, '-') else: correct+='?' if puzzle_word[2]==guess_word[2]: correct += puzzle_word[2] new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 2, '-') new_guess_word=replace_kth_letter_in_str(new_guess_word, 2, '-') else: correct+='?' if puzzle_word[3]==guess_word[3]: correct += puzzle_word[3] new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 3, '-') new_guess_word=replace_kth_letter_in_str(new_guess_word, 3, '-') else: correct+='?' if puzzle_word[4]==guess_word[4]: correct += puzzle_word[4] new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 4, '-') new_guess_word=replace_kth_letter_in_str(new_guess_word, 4, '-') else: correct+='?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): k=int(k) result = original_str[0:k]+ch+original_str[k+1:] return result def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0]!='-': wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0],puzzle_word), '-') else: wrong_position+='*' if guess_word[1] in puzzle_word and guess_word[1]!='-': wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1],puzzle_word), '-') else: wrong_position+='*' if guess_word[2] in puzzle_word and guess_word[2]!='-': wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2],puzzle_word), '-') else: wrong_position+='*' if guess_word[3] in puzzle_word and guess_word[3]!='-': wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3],puzzle_word), '-') else: wrong_position+='*' if guess_word[4] in puzzle_word and guess_word[4]!='-': wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4],puzzle_word), '-') else: wrong_position+='*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color=='green': if text[0]=='?': colored_text+='?' else: colored_text+=(white_on_green+text[0]+normal) if text[1]=='?': colored_text+='?' else: colored_text+=(white_on_green+text[1]+normal) if text[2]=='?': colored_text+='?' else: colored_text+=(white_on_green+text[2]+normal) if text[3]=='?': colored_text+='?' else: colored_text+=(white_on_green+text[3]+normal) if text[4]=='?': colored_text+='?' else: colored_text+=(white_on_green+text[4]+normal) else: if text[0]=='*': colored_text+='*' else: colored_text+=(white_on_yellow+text[0]+normal) if text[1]=='*': colored_text+='*' else: colored_text+=(white_on_yellow+text[1]+normal) if text[2]=='*': colored_text+='*' else: colored_text+=(white_on_yellow+text[2]+normal) if text[3]=='*': colored_text+='*' else: colored_text+=(white_on_yellow+text[3]+normal) if text[4]=='*': colored_text+='*' else: colored_text+=(white_on_yellow+text[4]+normal) return colored_text# 6432099021 sim = 84.63% import random import string def position_in_word(ch, word): position = -1 if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, "-") correct = correct + puzzle_word[0] else : correct = correct + "?" if puzzle_word[1] == guess_word[1] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, "-") correct = correct + puzzle_word[1] else : correct = correct + "?" if puzzle_word[2] == guess_word[2] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, "-") correct = correct + puzzle_word[2] else : correct = correct + "?" if puzzle_word[3] == guess_word[3] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, "-") correct = correct + puzzle_word[3] else : correct = correct + "?" if puzzle_word[4] == guess_word[4] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, "-") correct = correct + puzzle_word[4] else : correct = correct + "?" return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' new_puzzle_word = puzzle_word if position_in_word (guess_word[0], new_puzzle_word) != -1 and guess_word[0] != "-" : wrong_position = wrong_position + guess_word[0] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[0], new_puzzle_word), "-") else : wrong_position = wrong_position + "*" if position_in_word (guess_word[1], new_puzzle_word) != -1 and guess_word[1] != "-" : wrong_position = wrong_position + guess_word[1] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[1], new_puzzle_word), "-") else : wrong_position = wrong_position + "*" if position_in_word (guess_word[2], new_puzzle_word) != -1 and guess_word[2] != "-" : wrong_position = wrong_position + guess_word[2] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[2], new_puzzle_word), "-") else : wrong_position = wrong_position + "*" if position_in_word (guess_word[3], new_puzzle_word) != -1 and guess_word[3] != "-" : wrong_position = wrong_position + guess_word[3] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[3], new_puzzle_word), "-") else : wrong_position = wrong_position + "*" if position_in_word (guess_word[4], new_puzzle_word) != -1 and guess_word[4] != "-" : wrong_position = wrong_position + guess_word[4] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[4], new_puzzle_word), "-") else : wrong_position = wrong_position + "*" return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == "green" : changes = white_on_green else : changes = white_on_yellow colored_text = '' if text[0].isalpha() : colored_text = colored_text + changes + text[0] + normal else : colored_text = colored_text + text[0] if text[1].isalpha() : colored_text = colored_text + changes + text[1] + normal else : colored_text = colored_text + text[1] if text[2].isalpha() : colored_text = colored_text + changes + text[2] + normal else : colored_text = colored_text + text[2] if text[3].isalpha() : colored_text = colored_text + changes + text[3] + normal else : colored_text = colored_text + text[3] if text[4].isalpha() : colored_text = colored_text + changes + text[4] + normal else : colored_text = colored_text + text[4] return colored_text# 6430229021 sim = 83.99% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, "-") correct = replace_kth_letter_in_str(correct, 0, puzzle_word[0]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, "-") if puzzle_word[1] == guess_word[1]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, "-") correct = replace_kth_letter_in_str(correct, 1, puzzle_word[1]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, "-") if puzzle_word[2] == guess_word[2]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, "-") correct = replace_kth_letter_in_str(correct, 2, puzzle_word[2]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, "-") if puzzle_word[3] == guess_word[3]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, "-") correct = replace_kth_letter_in_str(correct, 3, puzzle_word[3]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, "-") if puzzle_word[4] == guess_word[4]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, "-") correct = replace_kth_letter_in_str(correct, 4, puzzle_word[4]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, "-") return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' ปริศนาฟ้าแล็บ = puzzle_word if guess_word[0] in ปริศนาฟ้าแล็บ and guess_word[0] != ปริศนาฟ้าแล็บ[0]: wrong_position = replace_kth_letter_in_str(wrong_position, 0, guess_word[0]) ปริศนาฟ้าแล็บ = replace_kth_letter_in_str(ปริศนาฟ้าแล็บ, position_in_word(guess_word[0], ปริศนาฟ้าแล็บ), "ง") if guess_word[1] in ปริศนาฟ้าแล็บ and guess_word[1] != ปริศนาฟ้าแล็บ[1]: wrong_position = replace_kth_letter_in_str(wrong_position, 1, guess_word[1]) ปริศนาฟ้าแล็บ = replace_kth_letter_in_str(ปริศนาฟ้าแล็บ, position_in_word(guess_word[1], ปริศนาฟ้าแล็บ), "ง") if guess_word[2] in ปริศนาฟ้าแล็บ and guess_word[2] != ปริศนาฟ้าแล็บ[2]: wrong_position = replace_kth_letter_in_str(wrong_position, 2, guess_word[2]) ปริศนาฟ้าแล็บ = replace_kth_letter_in_str(ปริศนาฟ้าแล็บ, position_in_word(guess_word[2], ปริศนาฟ้าแล็บ), "ง") if guess_word[3] in ปริศนาฟ้าแล็บ and guess_word[3] != ปริศนาฟ้าแล็บ[3]: wrong_position = replace_kth_letter_in_str(wrong_position, 3, guess_word[3]) ปริศนาฟ้าแล็บ = replace_kth_letter_in_str(ปริศนาฟ้าแล็บ, position_in_word(guess_word[3], ปริศนาฟ้าแล็บ), "ง") if guess_word[4] in ปริศนาฟ้าแล็บ and guess_word[4] != ปริศนาฟ้าแล็บ[4]: wrong_position = replace_kth_letter_in_str(wrong_position, 4, guess_word[4]) ปริศนาฟ้าแล็บ = replace_kth_letter_in_str(ปริศนาฟ้าแล็บ, position_in_word(guess_word[4], ปริศนาฟ้าแล็บ), "ง") return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text if "green" in color: if "A" <= text[0] <= "Z": colored_text = white_on_green + str(text[0])+ normal else: colored_text = text[0] if "A" <= text[1] <= "Z": colored_text += white_on_green + text[1] + normal else: colored_text += text[1] if "A" <= text[2] <= "Z": colored_text += white_on_green + text[2] + normal else: colored_text += text[2] if "A" <= text[3] <= "Z": colored_text += white_on_green + text[3] + normal else: colored_text += text[3] if "A" <= text[4] <= "Z": colored_text += white_on_green + text[4] + normal else: colored_text += text[4] elif "yellow" in color: if "A" <= text[0] <= "Z": colored_text = white_on_yellow + text[0] else: colored_text = normal + text[0] if "A" <= text[1] <= "Z": colored_text += white_on_yellow + text[1] else: colored_text += normal + text[1] if "A" <= text[2] <= "Z": colored_text += white_on_yellow + text[2] else: colored_text += normal + text[2] if "A" <= text[3] <= "Z": colored_text += white_on_yellow + text[3] else: colored_text += normal + text[3] if "A" <= text[4] <= "Z": colored_text += white_on_yellow + text[4] + normal else: colored_text += normal + text[4] return colored_text# 6430407321 sim = 83.99% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_puzzle_word = puzzle_word new_guess_word = guess_word if guess_word[0] == puzzle_word[0]: new_guess_word = replace_kth_letter_in_str(new_guess_word,0,"-") correct = replace_kth_letter_in_str(correct,0,guess_word[0]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,0,"-") if guess_word[1] == puzzle_word[1]: new_guess_word = replace_kth_letter_in_str(new_guess_word,1,"-") correct = replace_kth_letter_in_str(correct,1,guess_word[1]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,1,"-") if guess_word[2] == puzzle_word[2]: new_guess_word = replace_kth_letter_in_str(new_guess_word,2,"-") correct = replace_kth_letter_in_str(correct,2,guess_word[2]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,2,"-") if guess_word[3] == puzzle_word[3]: new_guess_word = replace_kth_letter_in_str(new_guess_word,3,"-") correct = replace_kth_letter_in_str(correct,3,guess_word[3]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,3,"-") if guess_word[4] == puzzle_word[4]: new_guess_word = replace_kth_letter_in_str(new_guess_word,4,"-") correct = replace_kth_letter_in_str(correct,4,guess_word[4]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,4,"-") return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k]+ ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' check = puzzle_word if guess_word[0] in check and guess_word[0] != '-' : wrong_position = replace_kth_letter_in_str(wrong_position,0,guess_word[0]) check = replace_kth_letter_in_str(check, position_in_word(guess_word[0], puzzle_word) ,"-") if guess_word[1] in check and guess_word[1] != '-' : wrong_position = replace_kth_letter_in_str(wrong_position,1,guess_word[1]) check = replace_kth_letter_in_str(check, position_in_word(guess_word[1], puzzle_word) ,"-") if guess_word[2] in check and guess_word[2] != '-' : wrong_position = replace_kth_letter_in_str(wrong_position,2,guess_word[2]) check = replace_kth_letter_in_str(check, position_in_word(guess_word[2], puzzle_word) ,"-") if guess_word[3] in check and guess_word[3] != '-' : wrong_position = replace_kth_letter_in_str(wrong_position,3,guess_word[3]) check = replace_kth_letter_in_str(check, position_in_word(guess_word[3], puzzle_word) ,"-") if guess_word[4] in check and guess_word[4] != '-' : wrong_position = replace_kth_letter_in_str(wrong_position,4,guess_word[4]) check = replace_kth_letter_in_str(check, position_in_word(guess_word[4], puzzle_word) ,"-") return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text == '*****' or text == '?????': return text else: if color == 'green': if text[0] != '?' and text[0] != '*': colored_text = white_on_green + text[0] + normal else: colored_text = text[0] if text[1] != '?' and text[1] != '*': colored_text += white_on_green + text[1] + normal else: colored_text += text[1] if text[2] != '?' and text[2] != '*': colored_text += white_on_green + text[2] + normal else: colored_text += text[2] if text[3] != '?' and text[3] != '*': colored_text += white_on_green + text[3] + normal else: colored_text += text[3] if text[4] != '?' and text[4] != '*': colored_text += white_on_green + text[4] + normal else: colored_text += text[4] elif color == 'yellow': if text[0] != '?' and text[0] != '*': colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if text[1] != '?' and text[1] != '*': colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if text[2] != '?' and text[2] != '*': colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if text[3] != '?' and text[3] != '*': colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if text[4] != '?' and text[4] != '*': colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text# 6432052521 sim = 83.83% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch : position = 0 elif word[1] == ch : position = 1 elif word[2] == ch : position = 2 elif word[3] == ch : position = 3 elif word[4] == ch : position = 4 elif not ch in word : position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if puzzle_word[0]==guess_word[0]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, "-") correct += puzzle_word[0] else : correct += '?' if puzzle_word[1]==guess_word[1]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, "-") correct += puzzle_word[1] else : correct += '?' if puzzle_word[2]==guess_word[2]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, "-") correct += puzzle_word[2] else : correct += '?' if puzzle_word[3]==guess_word[3]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, "-") correct += puzzle_word[3] else : correct += '?' if puzzle_word[4]==guess_word[4]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, "-") correct += puzzle_word[4] else : correct += '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): original_str = original_str[:k] + ch + original_str [k+1:] return original_str def check_wrong_position(puzzle_word, guess_word): wrong_position = '' new_puzzle_word = puzzle_word if position_in_word(guess_word[0], new_puzzle_word) != -1 and guess_word[0] != '-': wrong_position += guess_word[0] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[0], new_puzzle_word),"-") else : wrong_position += '*' if position_in_word(guess_word[1], new_puzzle_word) != -1 and guess_word[1] != '-': wrong_position += guess_word[1] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[1], new_puzzle_word),"-") else : wrong_position += '*' if position_in_word(guess_word[2], new_puzzle_word) != -1 and guess_word[2] != '-': wrong_position += guess_word[2] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[2], new_puzzle_word),"-") else : wrong_position += '*' if position_in_word(guess_word[3], new_puzzle_word) != -1 and guess_word[3] != '-': wrong_position += guess_word[3] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[3], new_puzzle_word),"-") else : wrong_position += '*' if position_in_word(guess_word[4], new_puzzle_word) != -1 and guess_word[4] != '-': wrong_position += guess_word[4] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[4], new_puzzle_word),"-") else : wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color =='green' : if text[0].isalpha() : colored_text += white_on_green + text[0] + normal else : colored_text += text[0] if text[1].isalpha() : colored_text += white_on_green + text[1] + normal else : colored_text += text[1] if text[2].isalpha() : colored_text += white_on_green + text[2] + normal else : colored_text += text[2] if text[3].isalpha() : colored_text += white_on_green + text[3] + normal else : colored_text += text[3] if text[4].isalpha() : colored_text += white_on_green + text[4] + normal else : colored_text += text[4] elif color=='yellow' : if text[0].isalpha() : colored_text += white_on_yellow + text[0] + normal else : colored_text += text[0] if text[1].isalpha() : colored_text += white_on_yellow + text[1] + normal else : colored_text += text[1] if text[2].isalpha() : colored_text += white_on_yellow + text[2] + normal else : colored_text += text[2] if text[3].isalpha() : colored_text += white_on_yellow + text[3] + normal else : colored_text += text[3] if text[4].isalpha() : colored_text += white_on_yellow + text[4] + normal else : colored_text += text[4] return colored_text# 6430241421 sim = 82.96% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch : position = 0 elif word[1] == ch : position = 1 elif word[2] == ch : position = 2 elif word[3] == ch : position = 3 elif word[4] == ch : position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0] : correct += puzzle_word[0] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,0,'-') new_guess_word = replace_kth_letter_in_str(new_guess_word,0,'-') else : correct += '?' if puzzle_word[1] == guess_word[1] : correct += puzzle_word[1] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,1,'-') new_guess_word = replace_kth_letter_in_str(new_guess_word,1,'-') else : correct += '?' if puzzle_word[2] == guess_word[2] : correct += puzzle_word[2] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,2,'-') new_guess_word = replace_kth_letter_in_str(new_guess_word,2,'-') else : correct += '?' if puzzle_word[3] == guess_word[3] : correct += puzzle_word[3] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,3,'-') new_guess_word = replace_kth_letter_in_str(new_guess_word,3,'-') else : correct += '?' if puzzle_word[4] == guess_word[4] : correct += puzzle_word[4] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,4,'-') new_guess_word = replace_kth_letter_in_str(new_guess_word,4,'-') else : correct += '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): a = original_str[:int(k)] + str(ch) + original_str[int(k)+1:] return a def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0] : wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'*') else : wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),'*') else : wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2],puzzle_word),'*') else : wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3],puzzle_word),'*') else : wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[4],puzzle_word),'*') else : wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if '*' in text : k = '*' else : k = '?' if text[0] != k and color == 'green' : colored_text += white_on_green + text[0] + normal elif text[0] != k and color == 'yellow' : colored_text += white_on_yellow + text[0] + normal else : colored_text += k if text[1] != k and color == 'green' : colored_text += white_on_green + text[1] + normal elif text[1] != k and color == 'yellow' : colored_text += white_on_yellow + text[1] + normal else : colored_text += k if text[2] != k and color == 'green' : colored_text += white_on_green + text[2] + normal elif text[2] != k and color == 'yellow' : colored_text += white_on_yellow + text[2] + normal else : colored_text += k if text[3] != k and color == 'green' : colored_text += white_on_green + text[3] + normal elif text[3] != k and color == 'yellow' : colored_text += white_on_yellow + text[3] + normal else : colored_text += k if text[4]!= k and color == 'green' : colored_text += white_on_green + text[4] + normal elif text[4] != k and color == 'yellow' : colored_text += white_on_yellow + text[4] + normal else : colored_text += k return colored_text# 6430313021 sim = 81.27% import random import string def position_in_word(ch, word): position = -1 if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, "-") correct = replace_kth_letter_in_str(correct, 0, guess_word[0]) if puzzle_word[1] == guess_word[1]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, "-") correct = replace_kth_letter_in_str(correct, 1, guess_word[1]) if puzzle_word[2] == guess_word[2]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, "-") correct = replace_kth_letter_in_str(correct, 2, guess_word[2]) if puzzle_word[3] == guess_word[3]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, "-") correct = replace_kth_letter_in_str(correct, 3, guess_word[3]) if puzzle_word[4] == guess_word[4]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, "-") correct = replace_kth_letter_in_str(correct, 4, guess_word[4]) return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' NPW = puzzle_word if guess_word[0] in NPW and guess_word[0] != puzzle_word[0]: wrong_position += guess_word[0] NPW = replace_kth_letter_in_str(NPW, position_in_word(guess_word[0], NPW), "不") else: wrong_position += "*" if guess_word[1] in NPW and guess_word[1] != puzzle_word[1]: wrong_position += guess_word[1] NPW = replace_kth_letter_in_str(NPW, position_in_word(guess_word[1], NPW), "不") else: wrong_position += "*" if guess_word[2] in NPW and guess_word[2] != puzzle_word[2]: wrong_position += guess_word[2] NPW = replace_kth_letter_in_str(NPW, position_in_word(guess_word[2], NPW), "不") else: wrong_position += "*" if guess_word[3] in NPW and guess_word[3] != puzzle_word[3]: wrong_position += guess_word[3] NPW = replace_kth_letter_in_str(NPW, position_in_word(guess_word[3], NPW), "不") else: wrong_position += "*" if guess_word[4] in NPW and guess_word[4] != puzzle_word[4]: wrong_position += guess_word[4] NPW = replace_kth_letter_in_str(NPW, position_in_word(guess_word[4], NPW), "不") else: wrong_position += "*" return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = "" if color == "green": if "A" <= text[0] <= "Z": colored_text += white_on_green + text[0] else:colored_text += normal + text[0] if "A" <= text[1] <= "Z": colored_text += white_on_green + text[1] else:colored_text += normal + text[1] if "A" <= text[2] <= "Z": colored_text += white_on_green + text[2] else:colored_text += normal + text[2] if "A" <= text[3] <= "Z": colored_text += white_on_green + text[3] else:colored_text += normal + text[3] if "A" <= text[4] <= "Z": colored_text += white_on_green + text[4] + normal else:colored_text += normal + text[4] if color == "yellow": if "A" <= text[0] <= "Z": colored_text += white_on_yellow + text[0] else:colored_text += normal + text[0] if "A" <= text[1] <= "Z": colored_text += white_on_yellow + text[1] else:colored_text += normal + text[1] if "A" <= text[2] <= "Z": colored_text += white_on_yellow + text[2] else:colored_text += normal + text[2] if "A" <= text[3] <= "Z": colored_text += white_on_yellow + text[3] else:colored_text += normal + text[3] if "A" <= text[4] <= "Z": colored_text += white_on_yellow + text[4] + normal else:colored_text += normal + text[4] return colored_text# 6430281521 sim = 81.26% import random import string def position_in_word(ch, word): position = -1 if ch in word: if ch==word[0]: position=0 elif ch==word[1]: position=1 elif ch==word[2]: position=2 elif ch==word[3]: position=3 elif ch==word[4]: position=4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word=guess_word correct = '?????' new_puzzle_word = puzzle_word if puzzle_word[0]==guess_word[0]: new_guess_word=replace_kth_letter_in_str(new_guess_word, 0, '-') correct=replace_kth_letter_in_str(correct, 0, puzzle_word[0]) new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 0, '-') if puzzle_word[1]==guess_word[1]: new_guess_word=replace_kth_letter_in_str(new_guess_word, 1, '-') correct=replace_kth_letter_in_str(correct, 1, puzzle_word[1]) new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 1, '-') if puzzle_word[2]==guess_word[2]: new_guess_word=replace_kth_letter_in_str(new_guess_word, 2, '-') correct=replace_kth_letter_in_str(correct, 2, puzzle_word[2]) new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 2, '-') if puzzle_word[3]==guess_word[3]: new_guess_word=replace_kth_letter_in_str(new_guess_word, 3, '-') correct=replace_kth_letter_in_str(correct, 3, puzzle_word[3]) new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 3, '-') if puzzle_word[4]==guess_word[4]: new_guess_word=replace_kth_letter_in_str(new_guess_word, 4, '-') correct=replace_kth_letter_in_str(correct, 4, puzzle_word[4]) new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 4, '-') return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): ori=original_str[:k]+str(ch)+original_str[k+1:] return ori def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' pword=puzzle_word if guess_word[0] in pword and guess_word[0]!=pword[0]: wrong_position=replace_kth_letter_in_str(wrong_position, 0, guess_word[0]) if position_in_word(guess_word[0], pword) != -1: pword=replace_kth_letter_in_str(pword, position_in_word(guess_word[0], pword), '-') if guess_word[1] in pword and guess_word[1]!=pword[1]: wrong_position=replace_kth_letter_in_str(wrong_position, 1, guess_word[1]) if position_in_word(guess_word[1], pword) != -1: pword=replace_kth_letter_in_str(pword, position_in_word(guess_word[1], pword), '-') if guess_word[2] in pword and guess_word[2]!=pword[2]: wrong_position=replace_kth_letter_in_str(wrong_position, 2, guess_word[2]) if position_in_word(guess_word[2], pword) != -1: pword=replace_kth_letter_in_str(pword, position_in_word(guess_word[2], pword), '-') if guess_word[3] in pword and guess_word[3]!=pword[3]: wrong_position=replace_kth_letter_in_str(wrong_position, 3, guess_word[3]) if position_in_word(guess_word[3], pword) != -1: pword=replace_kth_letter_in_str(pword, position_in_word(guess_word[3], pword), '-') if guess_word[4] in pword and guess_word[4]!=pword[4]: wrong_position=replace_kth_letter_in_str(wrong_position, 4, guess_word[4]) return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text='' if color=='green': if text[0]!='?' : colored_text+=white_on_green+text[0]+normal else : colored_text+=text[0] if text[1]!='?' : colored_text+=white_on_green+text[1]+normal else: colored_text+=text[1] if text[2]!='?' : colored_text+=white_on_green+text[2]+normal else: colored_text+=text[2] if text[3]!='?': colored_text+=white_on_green+text[3]+normal else: colored_text+=text[3] if text[4]!='?' : colored_text+=white_on_green+text[4]+normal else: colored_text+=text[4] elif color=='yellow': if text[0]!='*': colored_text+=white_on_yellow+text[0]+normal else : colored_text+=text[0] if text[1]!='*': colored_text+=white_on_yellow+text[1]+normal else: colored_text+=text[1] if text[2]!='*': colored_text+=white_on_yellow+text[2]+normal else: colored_text+=text[2] if text[3]!='*': colored_text+=white_on_yellow+text[3]+normal else: colored_text+=text[3] if text[4]!='*': colored_text+=white_on_yellow+text[4]+normal else: colored_text+=text[4] return colored_text# 6430203621 sim = 80.24% import random import string def position_in_word(ch, word): position = -1 if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_guess_word = guess_word new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0] : correct = replace_kth_letter_in_str(correct, 0,puzzle_word[0]) ; new_guess_word = replace_kth_letter_in_str(new_guess_word, 0,'-') ; new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0,'-') if puzzle_word[1] == guess_word[1] : correct = replace_kth_letter_in_str(correct, 1,puzzle_word[1]) ; new_guess_word = replace_kth_letter_in_str(new_guess_word, 1,'-') ; new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1,'-') if puzzle_word[2] == guess_word[2] : correct = replace_kth_letter_in_str(correct, 2,puzzle_word[2]) ; new_guess_word = replace_kth_letter_in_str(new_guess_word, 2,'-') ; new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2,'-') if puzzle_word[3] == guess_word[3] : correct = replace_kth_letter_in_str(correct, 3,puzzle_word[3]) ; new_guess_word = replace_kth_letter_in_str(new_guess_word, 3,'-') ; new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3,'-') if puzzle_word[4] == guess_word[4] : correct = replace_kth_letter_in_str(correct, 4,puzzle_word[4]) ; new_guess_word = replace_kth_letter_in_str(new_guess_word, 4,'-') ; new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4,'-') return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): if k == 0 : original_str = ch + original_str[1:] elif k == 1 : original_str = original_str[0] + ch + original_str[2:] elif k == 2 : original_str = original_str[:2] + ch + original_str[3:] elif k == 3 : original_str = original_str[:3] + ch + original_str[4] elif k == 4 : original_str = original_str[:4] + ch return original_str def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if puzzle_word[0] != guess_word[0] and guess_word[0] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position,0,guess_word[0]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') if puzzle_word[1] != guess_word[1] and guess_word[1] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position,1,guess_word[1]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),'-') if puzzle_word[2] != guess_word[2] and guess_word[2] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position,2,guess_word[2]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2],puzzle_word),'-') if puzzle_word[3] != guess_word[3] and guess_word[3] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position,3,guess_word[3]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3],puzzle_word),'-') if puzzle_word[4] != guess_word[4] and guess_word[4] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position,4,guess_word[4]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[4],puzzle_word),'-') return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' A = text[0] ; B = text[1] ; C = text[2] ; D = text[3] ; E = text[4] if 'green' in color: if '?' != text[0]: A = white_on_green + text[0] + normal if '?' != text[1]: B = white_on_green + text[1] + normal if '?' != text[2]: C = white_on_green + text[2] + normal if '?' != text[3]: D = white_on_green + text[3] + normal if '?' != text[4]: E = white_on_green + text[4] + normal elif 'yellow' in color: if '*' != text[0]: A = white_on_yellow + text[0] + normal if '*' != text[1]: B = white_on_yellow + text[1] + normal if '*' != text[2]: C = white_on_yellow + text[2] + normal if '*' != text[3]: D = white_on_yellow + text[3] + normal if '*' != text[4]: E = white_on_yellow + text[4] + normal colored_text = A+B+C+D+E return colored_text# 6430389721 sim = 80.24% import random import string def position_in_word(ch, word): if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' if puzzle_word[0] == guess_word[0] : correct = replace_kth_letter_in_str(correct,0,guess_word[0]) puzzle_word = replace_kth_letter_in_str(puzzle_word,0,'-') guess_word = replace_kth_letter_in_str(guess_word,0,'-') if puzzle_word[1] == guess_word[1] : correct = replace_kth_letter_in_str(correct,1,guess_word[1]) puzzle_word = replace_kth_letter_in_str(puzzle_word,1,'-') guess_word = replace_kth_letter_in_str(guess_word,1,'-') if puzzle_word[2] == guess_word[2] : correct = replace_kth_letter_in_str(correct,2,guess_word[2]) puzzle_word = replace_kth_letter_in_str(puzzle_word,2,'-') guess_word = replace_kth_letter_in_str(guess_word,2,'-') if puzzle_word[3] == guess_word[3] : correct = replace_kth_letter_in_str(correct,3,guess_word[3]) puzzle_word = replace_kth_letter_in_str(puzzle_word,3,'-') guess_word = replace_kth_letter_in_str(guess_word,3,'-') if puzzle_word[4] == guess_word[4] : correct = replace_kth_letter_in_str(correct,4,guess_word[4]) puzzle_word = replace_kth_letter_in_str(puzzle_word,4,'-') guess_word = replace_kth_letter_in_str(guess_word,4,'-') new_guess_word = guess_word new_puzzle_word = puzzle_word return new_guess_word,correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): ans = '' if k == 0 : ans = ch + original_str[1::] elif k == 1 : ans = original_str[0] + ch + original_str [2::] elif k == 2 : ans = original_str[0:2] + ch + original_str[3::] elif k == 3 : ans = original_str[0:3] + ch + original_str[4::] elif k == 4 : ans = original_str[0:4] + ch return ans def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] in puzzle_word and puzzle_word[0] != guess_word[0] : wrong_position = replace_kth_letter_in_str(wrong_position,0,guess_word[0]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'*') if guess_word[1] in puzzle_word and puzzle_word[1] != guess_word[1] : wrong_position = replace_kth_letter_in_str(wrong_position,1,guess_word[1]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),'*') if guess_word[2] in puzzle_word and puzzle_word[2] != guess_word[2] : wrong_position = replace_kth_letter_in_str(wrong_position,2,guess_word[2]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2],puzzle_word),'*') if guess_word[3] in puzzle_word and puzzle_word[3] != guess_word[3] : wrong_position = replace_kth_letter_in_str(wrong_position,3,guess_word[3]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3],puzzle_word),'*') if guess_word[4] in puzzle_word and puzzle_word[4] != guess_word[4] : wrong_position = replace_kth_letter_in_str(wrong_position,4,guess_word[4]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[4],puzzle_word),'*') return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text t1,t2,t3,t4,t5 = text[0],text[1],text[2],text[3],text[4], if color == 'green' : if t1 != '?' : t1 = white_on_green + t1 + normal if t2 != '?' : t2 = white_on_green + t2 + normal if t3 != '?' : t3 = white_on_green + t3 + normal if t4 != '?' : t4 = white_on_green + t4 + normal if t5 != '?' : t5 = white_on_green + t5 + normal if color == 'yellow' : if t1 != '*' : t1 = white_on_yellow + t1 + normal if t2 != '*' : t2 = white_on_yellow + t2 + normal if t3 != '*' : t3 = white_on_yellow + t3 + normal if t4 != '*' : t4 = white_on_yellow + t4 + normal if t5 != '*' : t5 = white_on_yellow + t5 + normal colored_text = t1+t2+t3+t4+t5 return colored_text# 6430282121 sim = 78.46% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_puzzle_word = puzzle_word new_guess_word = guess_word if puzzle_word[0] == guess_word[0]: correct = replace_kth_letter_in_str(correct, 0, puzzle_word[0]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, "-") if puzzle_word[1] == guess_word[1]: correct = replace_kth_letter_in_str(correct, 1, puzzle_word[1]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, "-") if puzzle_word[2] == guess_word[2]: correct = replace_kth_letter_in_str(correct, 2, puzzle_word[2]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, "-") if puzzle_word[3] == guess_word[3]: correct = replace_kth_letter_in_str(correct, 3, puzzle_word[3]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, "-") if puzzle_word[4] == guess_word[4]: correct = replace_kth_letter_in_str(correct, 4, puzzle_word[4]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, "-") return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] != puzzle_word[0] and guess_word[0] in puzzle_word: wrong_position = replace_kth_letter_in_str( wrong_position, 0, guess_word[0]) puzzle_word = replace_kth_letter_in_str( puzzle_word, position_in_word(guess_word[0], puzzle_word), "*") if guess_word[1] != puzzle_word[1] and guess_word[1] in puzzle_word: wrong_position = replace_kth_letter_in_str( wrong_position, 1, guess_word[1]) puzzle_word = replace_kth_letter_in_str( puzzle_word, position_in_word(guess_word[1], puzzle_word), "*") if guess_word[2] != puzzle_word[2] and guess_word[2] in puzzle_word: wrong_position = replace_kth_letter_in_str( wrong_position, 2, guess_word[2]) puzzle_word = replace_kth_letter_in_str( puzzle_word, position_in_word(guess_word[2], puzzle_word), "*") if guess_word[3] != puzzle_word[3] and guess_word[3] in puzzle_word: wrong_position = replace_kth_letter_in_str( wrong_position, 3, guess_word[3]) puzzle_word = replace_kth_letter_in_str( puzzle_word, position_in_word(guess_word[3], puzzle_word), "*") if guess_word[4] != puzzle_word[4] and guess_word[4] in puzzle_word: wrong_position = replace_kth_letter_in_str( wrong_position, 4, guess_word[4]) puzzle_word = replace_kth_letter_in_str( puzzle_word, position_in_word(guess_word[4], puzzle_word), "*") return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' clr = white_on_green if color == 'green' else white_on_yellow w1 = text[0] if text[0] in '*?' else clr + text[0] + normal w2 = text[1] if text[1] in '*?' else clr + text[1] + normal w3 = text[2] if text[2] in '*?' else clr + text[2] + normal w4 = text[3] if text[3] in '*?' else clr + text[3] + normal w5 = text[4] if text[4] in '*?' else clr + text[4] + normal return w1+w2+w3+w4+w5# 6430191721 sim = 77.43% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: new_guess_word = replace_kth_letter_in_str(guess_word, 0, '-') correct = replace_kth_letter_in_str(correct, 0, puzzle_word[0] ) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') if puzzle_word[1] == guess_word[1]: new_guess_word = replace_kth_letter_in_str(guess_word, 1, '-') correct = replace_kth_letter_in_str(correct, 1, puzzle_word[1] ) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') if puzzle_word[2] == guess_word[2]: new_guess_word = replace_kth_letter_in_str(guess_word, 2, '-') correct = replace_kth_letter_in_str(correct, 2, puzzle_word[2] ) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') if puzzle_word[3] == guess_word[3]: new_guess_word = replace_kth_letter_in_str(guess_word, 3, '-') correct = replace_kth_letter_in_str(correct, 3, puzzle_word[3] ) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') if puzzle_word[4] == guess_word[4]: new_guess_word = replace_kth_letter_in_str(guess_word, 4, '-') correct = replace_kth_letter_in_str(correct, 4, puzzle_word[4] ) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): replace_str = original_str[:k] + ch + original_str[k+1:] return replace_str def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] in puzzle_word and guess_word[0]!=puzzle_word[0]: wrong_position = replace_kth_letter_in_str(wrong_position, 0, guess_word[0]) if guess_word[1] in puzzle_word and guess_word[1]!=puzzle_word[1]: wrong_position = replace_kth_letter_in_str(wrong_position, 1, guess_word[1]) if guess_word[2] in puzzle_word and guess_word[2]!=puzzle_word[2]: wrong_position = replace_kth_letter_in_str(wrong_position, 2, guess_word[2]) if guess_word[3] in puzzle_word and guess_word[3]!=puzzle_word[3]: wrong_position = replace_kth_letter_in_str(wrong_position, 3, guess_word[3]) if guess_word[4] in puzzle_word and guess_word[4]!=puzzle_word[4]: wrong_position = replace_kth_letter_in_str(wrong_position, 4, guess_word[4]) return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text if color == 'green': if text[0]!='?': c = white_on_green + text[0] + normal else: c = text[0] if text[1]!='?': c += white_on_green + text[1] + normal else: c += text[1] if text[2]!='?': c += white_on_green + text[2] + normal else: c += text[2] if text[3]!='?': c += white_on_green + text[3] + normal else: c += text[3] if text[4]!='?': c += white_on_green + text[4] + normal else: c += text[4] colored_text = c elif color == 'yellow': if text[0]!='*': c = white_on_yellow + text[0] + normal else: c = text[0] if text[1]!='*': c += white_on_yellow + text[1] + normal else: c += text[1] if text[2]!='*': c += white_on_yellow + text[2] + normal else: c += text[2] if text[3]!='*': c += white_on_yellow + text[3] + normal else: c += text[3] if text[4]!='*': c += white_on_yellow + text[4] + normal else: c += text[4] colored_text = c return colored_text# 6430208821 sim = 76.99% import random import string def position_in_word(ch, word): if ch in word : if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_guess_word = guess_word new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0] : new_guess_word = replace_kth_letter_in_str(guess_word,0, '-') correct = replace_kth_letter_in_str(correct,0,puzzle_word[0]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word,0,'-') if guess_word[1] == puzzle_word[1] : new_guess_word = replace_kth_letter_in_str(guess_word,1, '-') correct = replace_kth_letter_in_str(correct,1,puzzle_word[1]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word,1,'-') if guess_word[2] == puzzle_word[2] : new_guess_word = replace_kth_letter_in_str(guess_word,2, '-') correct = replace_kth_letter_in_str(correct,2,puzzle_word[2]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word,2,'-') if guess_word[3] == puzzle_word[3] : new_guess_word = replace_kth_letter_in_str(guess_word,3, '-') correct = replace_kth_letter_in_str(correct,3,puzzle_word[3]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word,3,'-') if guess_word[4] == puzzle_word[4] : new_guess_word = replace_kth_letter_in_str(guess_word,4, '-') correct = replace_kth_letter_in_str(correct,4,puzzle_word[4]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word,4,'-') return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): replace_kth_letter_in_str = original_str if k == 0 : replace_kth_letter_in_str = ch + original_str[1:] elif k == 1 : replace_kth_letter_in_str = original_str[0] + ch + original_str[2:] elif k == 2 : replace_kth_letter_in_str = original_str[0:2] + ch + original_str[3:] elif k == 3 : replace_kth_letter_in_str = original_str[0:3] + ch + original_str[4] elif k == 4 : replace_kth_letter_in_str = original_str[0:4] + ch return replace_kth_letter_in_str def check_wrong_position(puzzle_word, guess_word): w = '*****' if guess_word[0] != puzzle_word[0] and guess_word[0] != '-' and guess_word[0] in puzzle_word : w = replace_kth_letter_in_str(w,0,guess_word[0]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') if guess_word[1] != puzzle_word[1] and guess_word[1] != '-' and guess_word[1] in puzzle_word : w = replace_kth_letter_in_str(w,1,guess_word[1]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),'-') if guess_word[2] != puzzle_word[2] and guess_word[2] != '-' and guess_word[2] in puzzle_word : w = replace_kth_letter_in_str(w,2,guess_word[2]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2],puzzle_word),'-') if guess_word[3] != puzzle_word[3] and guess_word[3] != '-' and guess_word[3] in puzzle_word : w = replace_kth_letter_in_str(w,3,guess_word[3]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3],puzzle_word),'-') if guess_word[4] != puzzle_word[4] and guess_word[4] != '-' and guess_word[4] in puzzle_word : w = replace_kth_letter_in_str(w,4,guess_word[4]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[4],puzzle_word),'-') return w def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == 'green' : if 'A' <= text[0] <= 'Z' : ch0 = white_on_green + text[0] + normal else : ch0 = text[0] if 'A' <= text[1] <= 'Z' : ch1 = white_on_green + text[1] + normal else : ch1 = text[1] if 'A' <= text[2] <= 'Z' : ch2 = white_on_green + text[2] + normal else : ch2 = text[2] if 'A' <= text[3] <= 'Z' : ch3 = white_on_green + text[3] + normal else : ch3 = text[3] if 'A' <= text[4] <= 'Z' : ch4 = white_on_green + text[4] + normal else : ch4 = text[4] if color == 'yellow' : if 'A' <= text[0] <= 'Z' : ch0 = white_on_yellow + text[0] + normal else : ch0 = text[0] if 'A' <= text[1] <= 'Z' : ch1 = white_on_yellow + text[1] + normal else : ch1 = text[1] if 'A' <= text[2] <= 'Z' : ch2 = white_on_yellow + text[2] + normal else : ch2 = text[2] if 'A' <= text[3] <= 'Z' : ch3 = white_on_yellow + text[3] + normal else : ch3 = text[3] if 'A' <= text[4] <= 'Z' : ch4 = white_on_yellow + text[4] + normal else : ch4 = text[4] colored_text = ch0 + ch1 + ch2 + ch3 + ch4 return colored_text# 6430239221 sim = 76.88% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_guess_word = guess_word new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') correct = replace_kth_letter_in_str(correct, 0, guess_word[0]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') if puzzle_word[1] == guess_word[1]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') correct = replace_kth_letter_in_str(correct, 1, guess_word[1]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') if puzzle_word[2] == guess_word[2]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') correct = replace_kth_letter_in_str(correct, 2, guess_word[2]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') if puzzle_word[3] == guess_word[3]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') correct = replace_kth_letter_in_str(correct, 3, guess_word[3]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') if puzzle_word[4] == guess_word[4]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') correct = replace_kth_letter_in_str(correct, 4, guess_word[4]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k + 1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != '-': wrong_position += guess_word[0] k = position_in_word(guess_word[0], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, k, '-') else: wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != '-': wrong_position += guess_word[1] k = position_in_word(guess_word[1], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, k, '-') else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != '-': wrong_position += guess_word[2] k = position_in_word(guess_word[2], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, k, '-') else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != '-': wrong_position += guess_word[3] k = position_in_word(guess_word[3], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, k, '-') else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != '-': wrong_position += guess_word[4] else: wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green': if 'A' <= text[0] <= 'Z': colored_text += white_on_green + text[0] + normal else: colored_text += text[0] if 'A' <= text[1] <= 'Z': colored_text += white_on_green + text[1] + normal else: colored_text += text[1] if 'A' <= text[2] <= 'Z': colored_text += white_on_green + text[2] + normal else: colored_text += text[2] if 'A' <= text[3] <= 'Z': colored_text += white_on_green + text[3] + normal else: colored_text += text[3] if 'A' <= text[4] <= 'Z': colored_text += white_on_green + text[4] + normal else: colored_text += text[4] else: if 'A' <= text[0] <= 'Z': colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if 'A' <= text[1] <= 'Z': colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if 'A' <= text[2] <= 'Z': colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if 'A' <= text[3] <= 'Z': colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if 'A' <= text[4] <= 'Z': colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text# 6430324921 sim = 76.86% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_puzzle_word = puzzle_word new_guess_word = guess_word if puzzle_word[0] == guess_word[0]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') correct = replace_kth_letter_in_str(correct, 0, puzzle_word[0]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word , 0, '-') if puzzle_word[1] == guess_word[1]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') correct = replace_kth_letter_in_str(correct, 1, puzzle_word[1]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word , 1, '-') if puzzle_word[2] == guess_word[2]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') correct = replace_kth_letter_in_str(correct, 2, puzzle_word[2]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word , 2, '-') if puzzle_word[3] == guess_word[3]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') correct = replace_kth_letter_in_str(correct, 3, puzzle_word[3]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word , 3, '-') if puzzle_word[4] == guess_word[4]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') correct = replace_kth_letter_in_str(correct, 4, puzzle_word[4]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word , 4, '-') return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] != '-': position = position_in_word(guess_word[0], puzzle_word) if position != -1: wrong_position = replace_kth_letter_in_str(wrong_position, 0, guess_word[0]) puzzle_word = replace_kth_letter_in_str(puzzle_word, position, '-') if guess_word[1] != '-': position = position_in_word(guess_word[1], puzzle_word) if position != -1: wrong_position = replace_kth_letter_in_str(wrong_position, 1, guess_word[1]) puzzle_word = replace_kth_letter_in_str(puzzle_word, position, '-') if guess_word[2] != '-': position = position_in_word(guess_word[2], puzzle_word) if position != -1: wrong_position = replace_kth_letter_in_str(wrong_position, 2, guess_word[2]) puzzle_word = replace_kth_letter_in_str(puzzle_word, position, '-') if guess_word[3] != '-': position = position_in_word(guess_word[3], puzzle_word) if position_in_word(guess_word[3], puzzle_word) != -1: wrong_position = replace_kth_letter_in_str(wrong_position, 3, guess_word[3]) puzzle_word = replace_kth_letter_in_str(puzzle_word, position, '-') if guess_word[4] != '-': position = position_in_word(guess_word[4], puzzle_word) if position != -1: wrong_position = replace_kth_letter_in_str(wrong_position, 4, guess_word[4]) puzzle_word = replace_kth_letter_in_str(puzzle_word, position, '-') return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green': if text[0] not in ['?', '*']: colored_text += white_on_green + text[0] + normal else: colored_text += text[0] if text[1] not in ['?', '*']: colored_text += white_on_green + text[1] + normal else: colored_text += text[1] if text[2] not in ['?', '*']: colored_text += white_on_green + text[2] + normal else: colored_text += text[2] if text[3] not in ['?', '*']: colored_text += white_on_green + text[3] + normal else: colored_text += text[3] if text[4] not in ['?', '*']: colored_text += white_on_green + text[4] + normal else: colored_text += text[4] return colored_text elif color == 'yellow': if text[0] not in ['?', '*']: colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if text[1] not in ['?', '*']: colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if text[2] not in ['?', '*']: colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if text[3] not in ['?', '*']: colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if text[4] not in ['?', '*']: colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text return text# 6231201321 sim = 76.73% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, "-") correct = correct + puzzle_word[0] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, "-") else : correct = correct + '?' if guess_word[1] == puzzle_word[1] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, "-") correct = correct + puzzle_word[1] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, "-") else : correct = correct + '?' if guess_word[2] == puzzle_word[2] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, "-") correct = correct + puzzle_word[2] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, "-") else : correct = correct + '?' if guess_word[3] == puzzle_word[3] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, "-") correct = correct + puzzle_word[3] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, "-") else : correct = correct + '?' if guess_word[4] == puzzle_word[4] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, "-") correct = correct + puzzle_word[4] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, "-") else : correct = correct + '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): x = original_str[:k] + "-" + original_str[k+1:] return x def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] == '-': wrong_position = wrong_position + '*' else : if guess_word[0] in puzzle_word: wrong_position = wrong_position + guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word),'$') else : wrong_position = wrong_position + '*' if guess_word[1] == '-': wrong_position = wrong_position + '*' else : if guess_word[1] in puzzle_word: wrong_position = wrong_position + guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word),'$') else : wrong_position = wrong_position + '*' if guess_word[2] == '-': wrong_position = wrong_position + '*' else : if guess_word[2] in puzzle_word: wrong_position = wrong_position + guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word),'$') else : wrong_position = wrong_position + '*' if guess_word[3] == '-': wrong_position = wrong_position + '*' else : if guess_word[3] in puzzle_word: wrong_position = wrong_position + guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word),'$') else : wrong_position = wrong_position + '*' if guess_word[4] == '-': wrong_position = wrong_position + '*' else : if guess_word[4] in puzzle_word: wrong_position = wrong_position + guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word),'$') else : wrong_position = wrong_position + '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if 'A' <= text[0] <= 'Z' : if color == 'green' : colored_text = colored_text + white_on_green + text[0] + normal if color == 'yellow' : colored_text = colored_text + white_on_yellow + text[0] + normal else : colored_text = colored_text + text[0] if 'A' <= text[1] <= 'Z' : if color == 'green' : colored_text = colored_text + white_on_green + text[1] + normal if color == 'yellow' : colored_text = colored_text + white_on_yellow + text[1] + normal else : colored_text = colored_text + text[1] if 'A' <= text[2] <= 'Z' : if color == 'green' : colored_text = colored_text + white_on_green + text[2] + normal if color == 'yellow' : colored_text = colored_text + white_on_yellow + text[2] + normal else : colored_text = colored_text + text[2] if 'A' <= text[3] <= 'Z' : if color == 'green' : colored_text = colored_text + white_on_green + text[3] + normal if color == 'yellow' : colored_text = colored_text + white_on_yellow + text[3] + normal else : colored_text = colored_text + text[3] if 'A' <= text[4] <= 'Z' : if color == 'green' : colored_text = colored_text + white_on_green + text[4] + normal if color == 'yellow' : colored_text = colored_text + white_on_yellow + text[4] + normal else : colored_text = colored_text + text[4] return colored_text# 6430255221 sim = 76.55% import random import string def position_in_word(ch, word): position = -1 if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0] : correct += guess_word[0] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') else : correct += '?' if guess_word[1] == puzzle_word[1] : correct += guess_word[1] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') else : correct += '?' if guess_word[2] == puzzle_word[2] : correct += guess_word[2] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') else : correct += '?' if guess_word[3] == puzzle_word[3] : correct += guess_word[3] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') else : correct += '?' if guess_word[4] == puzzle_word[4] : correct += guess_word[4] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') else : correct += '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): if k == 4 : original_str = original_str[:k] + ch elif k >= 0 and k < 4 : original_str = original_str[:k] + ch + original_str[k+1:] return original_str def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if position_in_word(guess_word[0], puzzle_word) == -1 or guess_word[0] == '-' : wrong_position += '*' else : wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), '-') if position_in_word(guess_word[1], puzzle_word) == -1 or guess_word[1] == '-' : wrong_position += '*' else : wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), '-') if position_in_word(guess_word[2], puzzle_word) == -1 or guess_word[2] == '-' : wrong_position += '*' else : wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), '-') if position_in_word(guess_word[3], puzzle_word) == -1 or guess_word[3] == '-' : wrong_position += '*' else : wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), '-') if position_in_word(guess_word[4], puzzle_word) == -1 or guess_word[4] == '-' : wrong_position += '*' else : wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), '-') return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green' : if 'A' <= text[0] <= 'Z' : colored_text += white_on_green + text[0] + normal else : colored_text += text[0] if 'A' <= text[1] <= 'Z' : colored_text += white_on_green + text[1] + normal else : colored_text += text[1] if 'A' <= text[2] <= 'Z' : colored_text += white_on_green + text[2] + normal else : colored_text += text[2] if 'A' <= text[3] <= 'Z' : colored_text += white_on_green + text[3] + normal else : colored_text += text[3] if 'A' <= text[4] <= 'Z' : colored_text += white_on_green + text[4] + normal else : colored_text += text[4] elif color == 'yellow' : if 'A' <= text[0] <= 'Z' : colored_text += white_on_yellow + text[0] + normal else : colored_text += text[0] if 'A' <= text[1] <= 'Z' : colored_text += white_on_yellow + text[1] + normal else : colored_text += text[1] if 'A' <= text[2] <= 'Z' : colored_text += white_on_yellow + text[2] + normal else : colored_text += text[2] if 'A' <= text[3] <= 'Z' : colored_text += white_on_yellow + text[3] + normal else : colored_text += text[3] if 'A' <= text[4] <= 'Z' : colored_text += white_on_yellow + text[4] + normal else : colored_text += text[4] return colored_text# 6430325521 sim = 75.88% import random import string def position_in_word(ch, word): position = -1 if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = "?????" new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0] : new_guess_word = "-"+guess_word[1]+guess_word[2]+guess_word[3]+guess_word[4] correct = replace_kth_letter_in_str(correct,0,puzzle_word[0]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,0,"-") if guess_word[1] == puzzle_word[1] : new_guess_word = new_guess_word[0]+"-"+guess_word[2]+guess_word[3]+guess_word[4] correct = replace_kth_letter_in_str(correct,1,puzzle_word[1]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,1,"-") if guess_word[2] == puzzle_word[2] : new_guess_word = new_guess_word[0]+new_guess_word[1]+"-"+guess_word[3]+guess_word[4] correct = replace_kth_letter_in_str(correct,2,puzzle_word[2]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,2,"-") if guess_word[3] == puzzle_word[3] : new_guess_word = new_guess_word[0]+new_guess_word[1]+new_guess_word[2]+"-"+guess_word[4] correct = replace_kth_letter_in_str(correct,3,puzzle_word[3]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,3,"-") if guess_word[4] == puzzle_word[4] : new_guess_word = new_guess_word[0]+new_guess_word[1]+new_guess_word[2]+new_guess_word[3]+"-" correct = replace_kth_letter_in_str(correct,4,puzzle_word[4]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,4,"-") return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): if k == 0 : x = ch+original_str[1:5] elif k == 1 : x = original_str[0]+ch+original_str[2:5] elif k == 2 : x = original_str[:2]+ch+original_str[3:5] elif k == 3 : x = original_str[:3]+ch+original_str[4] elif k == 4 : x = original_str[:4]+ch return x def check_wrong_position(puzzle_word, guess_word): wrong_position = "*****" if guess_word[0] != "-" : if guess_word[0] in puzzle_word : wrong_position = replace_kth_letter_in_str(wrong_position,0,guess_word[0]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),"*") if guess_word[1] != "-" : if guess_word[1] in puzzle_word : wrong_position = replace_kth_letter_in_str(wrong_position,1,guess_word[1]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),"*") if guess_word[2] != "-" : if guess_word[2] in puzzle_word : wrong_position = replace_kth_letter_in_str(wrong_position,2,guess_word[2]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2],puzzle_word),"*") if guess_word[3] != "-" : if guess_word[3] in puzzle_word : wrong_position = replace_kth_letter_in_str(wrong_position,3,guess_word[3]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3],puzzle_word),"*") if guess_word[4] != "-" : if guess_word[4] in puzzle_word : wrong_position = replace_kth_letter_in_str(wrong_position,4,guess_word[4]) puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[4],puzzle_word),"*") return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == "green" : a = white_on_green elif color == "yellow" : a = white_on_yellow else : return text if text[0] != "?" and text[0] != "*" : colored_text = a + text[0] + normal else : colored_text += text[0] if text[1] != "?" and text[1] != "*" : colored_text += a + text[1] + normal else : colored_text += text[1] if text[2] != "?" and text[2] != "*" : colored_text += a + text[2] + normal else : colored_text += text[2] if text[3] != "?" and text[3] != "*" : colored_text += a + text[3] + normal else : colored_text += text[3] if text[4] != "?" and text[4] != "*" : colored_text += a + text[4] + normal else : colored_text += text[4] return colored_text# 6430215121 sim = 75.79% import random import string def position_in_word(ch, word): if word[0] == ch: return 0 elif word[1] == ch: return 1 elif word[2] == ch: return 2 elif word[3] == ch: return 3 elif word[4] == ch: return 4 return -1 def check_correct_position(puzzle_word, guess_word): correct = "?????" new_guess_word = guess_word new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: correct = replace_kth_letter_in_str(correct, 0, puzzle_word[0]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, "-") if guess_word[1] == puzzle_word[1]: correct = replace_kth_letter_in_str(correct, 1, puzzle_word[1]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, "-") if guess_word[2] == puzzle_word[2]: correct = replace_kth_letter_in_str(correct, 2, puzzle_word[2]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, "-") if guess_word[3] == puzzle_word[3]: correct = replace_kth_letter_in_str(correct, 3, puzzle_word[3]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, "-") if guess_word[4] == puzzle_word[4]: correct = replace_kth_letter_in_str(correct, 4, puzzle_word[4]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, "-") return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k + 1 :] def check_wrong_position(puzzle_word, guess_word): wrong_position = "*****" k = position_in_word(guess_word[0], puzzle_word) if guess_word[0] != "-" and k != -1: wrong_position = replace_kth_letter_in_str(wrong_position, 0, guess_word[0]) puzzle_word = replace_kth_letter_in_str(puzzle_word, k, "-") k = position_in_word(guess_word[1], puzzle_word) if guess_word[1] != "-" and k != -1: wrong_position = replace_kth_letter_in_str(wrong_position, 1, guess_word[1]) puzzle_word = replace_kth_letter_in_str(puzzle_word, k, "-") k = position_in_word(guess_word[2], puzzle_word) if guess_word[2] != "-" and k != -1: wrong_position = replace_kth_letter_in_str(wrong_position, 2, guess_word[2]) puzzle_word = replace_kth_letter_in_str(puzzle_word, k, "-") k = position_in_word(guess_word[3], puzzle_word) if guess_word[3] != "-" and k != -1: wrong_position = replace_kth_letter_in_str(wrong_position, 3, guess_word[3]) puzzle_word = replace_kth_letter_in_str(puzzle_word, k, "-") k = position_in_word(guess_word[4], puzzle_word) if guess_word[4] != "-" and k != -1: wrong_position = replace_kth_letter_in_str(wrong_position, 4, guess_word[4]) puzzle_word = replace_kth_letter_in_str(puzzle_word, k, "-") return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = "" t = text color_code = white_on_green if color == "green" else white_on_yellow if t[0] != '?' and t[0] != '*': colored_text += color_code + t[0] + normal else: colored_text += t[0] if t[1] != '?' and t[1] != '*': colored_text += color_code + t[1] + normal else: colored_text += t[1] if t[2] != '?' and t[2] != '*': colored_text += color_code + t[2] + normal else: colored_text += t[2] if t[3] != '?' and t[3] != '*': colored_text += color_code + t[3] + normal else: colored_text += t[3] if t[4] != '?' and t[4] != '*': colored_text += color_code + t[4] + normal else: colored_text += t[4] return colored_text# 6432188221 sim = 75.48% import random import string def position_in_word(ch, word): position = -1 if word[0]==ch : position =0 elif word[1]==ch : position =1 elif word[2]==ch : position =2 elif word[3]==ch : position =3 elif word[4]==ch : position =4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') correct += guess_word[0] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') else: correct += '?' if puzzle_word[1] == guess_word[1]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') correct += guess_word[1] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') else: correct += '?' if puzzle_word[2] == guess_word[2]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') correct += guess_word[2] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') else: correct += '?' if puzzle_word[3] == guess_word[3]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') correct += guess_word[3] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') else: correct += '?' if puzzle_word[4] == guess_word[4]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') correct += guess_word[4] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') else: correct += '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): new_str = original_str if k==0: new_str = ch + new_str[1:] elif k==1: new_str = new_str[:0] + ch + new_str[2:] elif k==2: new_str = new_str[:2] + ch + new_str[3:] elif k==3: new_str = new_str[:3] + ch + new_str[4:] elif k==4: new_str = new_str[:4] + ch return new_str def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if (guess_word[0] in puzzle_word) and guess_word[0]!= '-' : wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), '-') else: wrong_position += '*' if (guess_word[1] in puzzle_word) and guess_word[1]!= '-' : wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), '-') else: wrong_position += '*' if (guess_word[2] in puzzle_word) and guess_word[2]!= '-' : wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), '-') else: wrong_position += '*' if (guess_word[3] in puzzle_word) and guess_word[3]!= '-' : wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), '-') else: wrong_position += '*' if (guess_word[4] in puzzle_word) and guess_word[4]!= '-' : wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), '-') else: wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text="" if color=='green': co = white_on_green else: co = white_on_yellow if text[0]!='?' and text[0]!='*': colored_text = colored_text + co + text[0] + normal else: colored_text = colored_text + text[0] if text[1]!='?' and text[1]!='*': colored_text = colored_text + co + text[1] + normal else: colored_text = colored_text + text[1] if text[2]!='?' and text[2]!='*': colored_text = colored_text + co + text[2] + normal else: colored_text = colored_text + text[2] if text[3]!='?' and text[3]!='*': colored_text = colored_text + co + text[3] + normal else: colored_text = colored_text + text[3] if text[4]!='?' and text[4]!='*': colored_text = colored_text + co + text[4] + normal else: colored_text = colored_text + text[4] return colored_text# 6430274121 sim = 74.8% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' if guess_word[0] == puzzle_word[0]: correct = replace_kth_letter_in_str(correct,0,puzzle_word[0] ) puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') guess_word = replace_kth_letter_in_str(guess_word, 0, '-') if guess_word[1] == puzzle_word[1]: correct = replace_kth_letter_in_str(correct,1,puzzle_word[1] ) puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') guess_word = replace_kth_letter_in_str(guess_word, 1, '-') if guess_word[2] == puzzle_word[2]: correct = replace_kth_letter_in_str(correct,2,puzzle_word[2] ) puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') guess_word = replace_kth_letter_in_str(guess_word, 2, '-') if guess_word[3] == puzzle_word[3]: correct = replace_kth_letter_in_str(correct,3,puzzle_word[3] ) puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') guess_word = replace_kth_letter_in_str(guess_word, 3, '-') if guess_word[4] == puzzle_word[4]: correct = replace_kth_letter_in_str(correct,4,puzzle_word[4] ) puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') guess_word = replace_kth_letter_in_str(guess_word, 4, '-') new_puzzle_word = puzzle_word new_guess_word = guess_word return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): transform = original_str[0:k]+ch+original_str[k+1:] return transform def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] in puzzle_word and guess_word[0] !='-': wrong_position = replace_kth_letter_in_str(wrong_position,0,guess_word[0]) x = position_in_word(guess_word[0],puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word,x,'-') if guess_word[1] in puzzle_word and guess_word[1] !='-': wrong_position = replace_kth_letter_in_str(wrong_position,1,guess_word[1]) x = position_in_word(guess_word[1],puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word,x,'-') if guess_word[2] in puzzle_word and guess_word[2] !='-': wrong_position = replace_kth_letter_in_str(wrong_position,2,guess_word[2]) x = position_in_word(guess_word[2],puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word,x,'-') if guess_word[3] in puzzle_word and guess_word[3] !='-': wrong_position = replace_kth_letter_in_str(wrong_position,3,guess_word[3]) x = position_in_word(guess_word[3],puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word,x,'-') if guess_word[4] in puzzle_word and guess_word[4] != '-': wrong_position = replace_kth_letter_in_str(wrong_position,4,guess_word[4]) x = position_in_word(guess_word[4],puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word,x,'-') return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' alphabet_list = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] text =list(text) if color == 'green': color = white_on_green elif color == 'yellow': color = white_on_yellow if text[0] in alphabet_list: text[0] = color + text[0] + normal if text[1] in alphabet_list: text[1] = color + text[1] + normal if text[2] in alphabet_list: text[2] = color + text[2] + normal if text[3] in alphabet_list: text[3] = color + text[3] + normal if text[4] in alphabet_list: text[4] = color + text[4] + normal colored_text = ''.join(text) return colored_text# 6430288021 sim = 74.7% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if new_puzzle_word[0] == guess_word[0]: correct += guess_word[0] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') elif new_puzzle_word[0] != guess_word[0]: correct += '?' if new_puzzle_word[1] == guess_word[1]: correct += guess_word[1] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') elif new_puzzle_word[1] != guess_word[1]: correct += '?' if new_puzzle_word[2] == guess_word[2]: correct += guess_word[2] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') elif new_puzzle_word[2] != guess_word[2]: correct += '?' if new_puzzle_word[3] == guess_word[3]: correct += guess_word[3] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') elif new_puzzle_word[3] != guess_word[3]: correct += '?' if new_puzzle_word[4] == guess_word[4]: correct += guess_word[4] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') elif new_puzzle_word[4] != guess_word[4]: correct += '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): if k == 0: replaced_word = ch + original_str[1:] elif k == 1: replaced_word = original_str[0] + ch + original_str[2:] elif k == 2: replaced_word = original_str[0:2:] + ch + original_str[3:] elif k == 3: replaced_word = original_str[0:3:] + ch + original_str[4:] elif k == 4: replaced_word = original_str[0:4:] + ch return replaced_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != '-': wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), '-') else: wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != '-': wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), '-') else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != '-': wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), '-') else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != '-': wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), '-') else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != '-': wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), '-') else: wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text[0] not in ['?','*'] and color == 'green': colored_text += white_on_green + text[0] + normal elif text[0] not in ['?','*'] and color == 'yellow': colored_text += white_on_yellow + text[0] + normal elif text[0] in ['?','*']: colored_text += text[0] if text[1] not in ['?','*'] and color == 'green': colored_text += white_on_green + text[1] + normal elif text[1] not in ['?','*'] and color == 'yellow': colored_text += white_on_yellow + text[1] + normal elif text[1] in ['?','*']: colored_text += text[1] if text[2] not in ['?','*'] and color == 'green': colored_text += white_on_green + text[2] + normal elif text[2] not in ['?','*'] and color == 'yellow': colored_text += white_on_yellow + text[2] + normal elif text[2] in ['?','*']: colored_text += text[2] if text[3] not in ['?','*'] and color == 'green': colored_text += white_on_green + text[3] + normal elif text[3] not in ['?','*'] and color == 'yellow': colored_text += white_on_yellow + text[3] + normal elif text[3] in ['?','*']: colored_text += text[3] if text[4] not in ['?','*'] and color == 'green': colored_text += white_on_green + text[4] + normal elif text[4] not in ['?','*'] and color == 'yellow': colored_text += white_on_yellow + text[4] + normal elif text[4] in ['?','*']: colored_text += text[4] return colored_text# 6430378821 sim = 74.49% import random import string def position_in_word(ch, word): if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = '' if puzzle_word[0] == guess_word[0]: new_guess_word = replace_kth_letter_in_str(guess_word, 0, '-') correct += puzzle_word[0] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') else: new_guess_word = replace_kth_letter_in_str(guess_word, 0, guess_word[0]) correct += '?' new_puzzle_word += puzzle_word[0] if puzzle_word[1] == guess_word[1]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') correct += puzzle_word[1] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') else: new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, guess_word[1]) correct += '?' new_puzzle_word += puzzle_word[1] if puzzle_word[2] == guess_word[2]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') correct += puzzle_word[2] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') else: new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, guess_word[2]) correct += '?' new_puzzle_word += puzzle_word[2] if puzzle_word[3] == guess_word[3]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') correct += puzzle_word[3] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') else: new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, guess_word[3]) correct += '?' new_puzzle_word += puzzle_word[3] if puzzle_word[4] == guess_word[4]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') correct += puzzle_word[4] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') else: new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, guess_word[4]) correct += '?' new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[0:k] + ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0]: wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),'-') else: wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),'-') else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2],puzzle_word),'-') else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3],puzzle_word),'-') else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[4],puzzle_word),'*') else: wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' text_color = '' if 'A' <= text[0] <= 'Z': if color == 'green': text_color += white_on_green + text[0] + normal else: text_color += white_on_yellow + text[0] + normal else: text_color += text[0] if 'A' <= text[1] <= 'Z': if color == 'green': text_color += white_on_green + text[1] + normal else: text_color += white_on_yellow + text[1] + normal else: text_color += text[1] if 'A' <= text[2] <= 'Z': if color == 'green': text_color += white_on_green + text[2] + normal else: text_color += white_on_yellow + text[2] + normal else: text_color += text[2] if 'A' <= text[3] <= 'Z': if color == 'green': text_color += white_on_green + text[3] + normal else: text_color += white_on_yellow + text[3] + normal else: text_color += text[3] if 'A' <= text[4] <= 'Z': if color == 'green': text_color += white_on_green + text[4] + normal else: text_color += white_on_yellow + text[4] + normal else: text_color += text[4] colored_text = text_color return colored_text# 6432118321 sim = 74.23% import random import string def position_in_word(ch, word): if ch in word: if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, "-") correct = replace_kth_letter_in_str(correct, 0, puzzle_word[0]) if puzzle_word[1] == guess_word[1]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, "-") correct = replace_kth_letter_in_str(correct, 1, puzzle_word[1]) if puzzle_word[2] == guess_word[2]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, "-") correct = replace_kth_letter_in_str(correct, 2, puzzle_word[2]) if puzzle_word[3] == guess_word[3]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, "-") correct = replace_kth_letter_in_str(correct, 3, puzzle_word[3]) if puzzle_word[4] == guess_word[4]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, "-") new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, "-") correct = replace_kth_letter_in_str(correct, 4, puzzle_word[4]) return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): original_str = original_str[:k] + ch + original_str[k+1:] return original_str def check_wrong_position(puzzle_word, guess_word): word = "*****" if guess_word[0] in puzzle_word: if guess_word[0] != puzzle_word[0]: word = replace_kth_letter_in_str(word, 0, guess_word[0]) x = position_in_word(guess_word[0], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, x, " ") if guess_word[1] in puzzle_word: if guess_word[1] != puzzle_word[1]: word = replace_kth_letter_in_str(word, 1, guess_word[1]) x = position_in_word(guess_word[1], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, x, " ") if guess_word[2] in puzzle_word: if guess_word[2] != puzzle_word[2] : word = replace_kth_letter_in_str(word, 2, guess_word[2]) x = position_in_word(guess_word[2], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, x, " ") if guess_word[3] in puzzle_word: if guess_word[3] != puzzle_word[3]: word = replace_kth_letter_in_str(word, 3, guess_word[3]) x = position_in_word(guess_word[3], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, x, " ") if guess_word[4] in puzzle_word: if guess_word[4] != puzzle_word[4]: word = replace_kth_letter_in_str(word, 4, guess_word[4]) x = position_in_word(guess_word[4], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, x, " ") if guess_word == puzzle_word: word = "*****" wrong_position = word return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' ch1 = text[0] ch2 = text[1] ch3 = text[2] ch4 = text[3] ch5 = text[4] if color == 'green': if 'A' <= ch1 <= 'Z': ch1 = white_on_green + ch1 + normal if 'A' <= ch2 <= 'Z': ch2 = white_on_green + ch2 + normal if 'A' <= ch3 <= 'Z': ch3 = white_on_green + ch3 + normal if 'A' <= ch4 <= 'Z': ch4 = white_on_green + ch4 + normal if 'A' <= ch5 <= 'Z': ch5 = white_on_green + ch5 + normal elif color == "yellow": if 'A' <= ch1 <= 'Z' : ch1 = white_on_yellow + ch1 + normal if 'A' <= ch2 <= 'Z' : ch2 = white_on_yellow + ch2 + normal if 'A' <= ch3 <= 'Z' : ch3 = white_on_yellow + ch3 + normal if 'A' <= ch4 <= 'Z' : ch4 = white_on_yellow + ch4 + normal if 'A' <= ch5 <= 'Z' : ch5 = white_on_yellow + ch5 + normal colored_text = text = ch1 + ch2 + ch3 + ch4 + ch5 return colored_text# 6432116021 sim = 73.68% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch : position = 0 elif word[1] == ch : position = 1 elif word[2] == ch : position = 2 elif word[3] == ch : position = 3 elif word[4] == ch : position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0 ," - ") new_guess_word = replace_kth_letter_in_str(new_guess_word, 0 ," - ") correct = correct + puzzle_word[0] else : correct = correct + "?" if puzzle_word[1] == guess_word[1]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1 ," - ") new_guess_word = replace_kth_letter_in_str(new_guess_word, 1 ," - ") correct = correct + puzzle_word[1] else : correct = correct + "?" if puzzle_word[2] == guess_word[2]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2 ," - ") new_guess_word = replace_kth_letter_in_str(new_guess_word, 2 ," - ") correct = correct + puzzle_word[2] else : correct = correct + "?" if puzzle_word[3] == guess_word[3]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3 ," - ") new_guess_word = replace_kth_letter_in_str(new_guess_word, 3 ," - ") correct = correct + puzzle_word[3] else : correct = correct + "?" if puzzle_word[4] == guess_word[4]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4 ," - ") new_guess_word = replace_kth_letter_in_str(new_guess_word, 4 ," - ") correct = correct + puzzle_word[4] else : correct = correct + "?" return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): x1 = original_str[:k] x2 = original_str[k + 1:] return x1 + ch + x2 def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and puzzle_word[0] != guess_word[0] : wrong_position = wrong_position + guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0],puzzle_word), '-') else : wrong_position = wrong_position + '*' if guess_word[1] in puzzle_word and puzzle_word[1] != guess_word[1] : wrong_position = wrong_position + guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1],puzzle_word), '-') else : wrong_position = wrong_position + '*' if guess_word[2] in puzzle_word and puzzle_word[2] != guess_word[2] : wrong_position = wrong_position + guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2],puzzle_word), '-') else : wrong_position = wrong_position + '*' if guess_word[3] in puzzle_word and puzzle_word[3] != guess_word[3] : wrong_position = wrong_position + guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3],puzzle_word), '-') else : wrong_position = wrong_position + '*' if guess_word[4] in puzzle_word and puzzle_word[4] != guess_word[4] : wrong_position = wrong_position + guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0],puzzle_word), '-') else : wrong_position = wrong_position + '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' u = ['*']*5 v = ['?']*5 p = [text[0],text[1],text[2],text[3],text[4]] if color == "yellow": color_mean ='\033[34;43m' if color == "green": color_mean= '\033[37;42m' normal = '\033[0;0m' if p[0] not in u and p[0] not in v: p[0] = color_mean + p[0] + normal if p[1] not in u and p[1] not in v: p[1] = color_mean + p[1] + normal if p[2] not in u and p[2] not in v: p[2] = color_mean + p[2] + normal if p[3] not in u and p[3] not in v: p[3] = color_mean + p[3] + normal if p[4] not in u and p[4] not in v: p[4] = color_mean + p[4] + normal colored_text = p[0] + p[1]+ p[2]+ p[3]+ p[4] return colored_text# 6430440021 sim = 73.04% import random import string def position_in_word(ch, word): if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word b = ['?','?','?','?','?'] new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, "-") b[0] = guess_word[0] if puzzle_word[1] == guess_word[1]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, "-") b[1] = guess_word[1] if puzzle_word[2] == guess_word[2]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, "-") b[2] = guess_word[2] if puzzle_word[3] == guess_word[3]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, "-") b[3] = guess_word[3] if puzzle_word[4] == guess_word[4]: new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, "-") b[4] = guess_word[4] correct = b[0] + b[1] + b[2] + b[3] + b[4] return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[0:k:1] + '-' + original_str[k+1:len(original_str):1] def check_wrong_position(puzzle_word, guess_word): new_puzzle_word = puzzle_word wrong_position = '' if position_in_word(guess_word[0], new_puzzle_word) != -1 and guess_word[0] != "-": new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[0], new_puzzle_word), "-") wrong_position += guess_word[0] else: wrong_position += "*" if position_in_word(guess_word[1], new_puzzle_word) != -1 and guess_word[1] != "-": new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[1], new_puzzle_word), "-") wrong_position += guess_word[1] else: wrong_position += "*" if position_in_word(guess_word[2], new_puzzle_word) != -1 and guess_word[2] != "-": new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[2], new_puzzle_word), "-") wrong_position += guess_word[2] else: wrong_position += "*" if position_in_word(guess_word[3], new_puzzle_word) != -1 and guess_word[3] != "-": new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[3], new_puzzle_word), "-") wrong_position += guess_word[3] else: wrong_position += "*" if position_in_word(guess_word[4], new_puzzle_word) != -1 and guess_word[4] != "-": new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[4], new_puzzle_word), "-") wrong_position += guess_word[4] else: wrong_position += "*" return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = "" if text[0] != '?' and text[0] != '*' and color == 'green': colored_text+=white_on_green + text[0] + normal elif text[0] != '?' and text[0] != '*' and color == 'yellow': colored_text+=white_on_yellow + text[0] + normal else: colored_text+=text[0] if text[1] != '?' and text[1] != '*' and color == 'green': colored_text+=white_on_green + text[1] + normal elif text[1] != '?' and text[1] != '*' and color == 'yellow': colored_text+=white_on_yellow + text[1] + normal else: colored_text+=text[1] if text[2] != '?' and text[2] != '*' and color == 'green': colored_text+=white_on_green + text[2] + normal elif text[2] != '?' and text[2] != '*' and color == 'yellow': colored_text+=white_on_yellow + text[2] + normal else: colored_text+=text[2] if text[3] != '?' and text[3] != '*' and color == 'green': colored_text+=white_on_green + text[3] + normal elif text[3] != '?' and text[3] != '*' and color == 'yellow': colored_text+=white_on_yellow + text[3] + normal else: colored_text+=text[3] if text[4] != '?' and text[4] != '*' and color == 'green': colored_text+=white_on_green + text[4] + normal elif text[4] != '?' and text[4] != '*' and color == 'yellow': colored_text+=white_on_yellow + text[4] + normal else: colored_text+=text[4] return colored_text# 6430424021 sim = 72.89% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position= 1 elif ch == word[2]: position = 2 elif ch == word[3]: position =3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0] : correct = replace_kth_letter_in_str(correct, 0, guess_word[0]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') if puzzle_word[1] == guess_word[1] : correct = replace_kth_letter_in_str(correct, 1, guess_word[1]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') if puzzle_word[2] == guess_word[2] : correct = replace_kth_letter_in_str(correct, 2, guess_word[2]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') if puzzle_word[3] == guess_word[3] : correct = replace_kth_letter_in_str(correct, 3, guess_word[3]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') if puzzle_word[4] == guess_word[4] : correct = replace_kth_letter_in_str(correct, 4, guess_word[4]) new_puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') return new_guess_word,correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): original_str = original_str[:k]+ch+original_str[k+1:] return original_str def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if position_in_word(guess_word[0], puzzle_word) != -1 and guess_word[0] != puzzle_word[0] and guess_word[0] != '-': wrong_position = replace_kth_letter_in_str(wrong_position, 0, guess_word[0]) if position_in_word(guess_word[1], puzzle_word) != -1 and guess_word[1] != puzzle_word[1] and guess_word[1] != '-': wrong_position = replace_kth_letter_in_str(wrong_position, 1, guess_word[1]) if position_in_word(guess_word[2], puzzle_word) != -1 and guess_word[2] != puzzle_word[2] and guess_word[2] != '-': wrong_position = replace_kth_letter_in_str(wrong_position, 2, guess_word[2]) if position_in_word(guess_word[3], puzzle_word) != -1 and guess_word[3] != puzzle_word[3] and guess_word[3] != '-': wrong_position = replace_kth_letter_in_str(wrong_position, 3, guess_word[3]) if position_in_word(guess_word[4], puzzle_word) != -1 and guess_word[4] != puzzle_word[4] and guess_word[4] != '-': wrong_position = replace_kth_letter_in_str(wrong_position, 4, guess_word[4]) return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' a = [text[0],text[1],text[2],text[3],text[4]] if color == 'green' : color = white_on_green if text[0] != '*' and text[0] != '?' : a[0] = color + text[0] + normal if text[1] != '*' and text[1] != '?' : a[1] = color + text[1] + normal if text[2] != '*' and text[2] != '?' : a[2] = color + text[2] + normal if text[3] != '*' and text[3] != '?' : a[3] = color + text[3] + normal if text[4] != '*' and text[4] != '?' : a[4] = color + text[4] + normal elif color == 'yellow' : color = white_on_yellow if text[0] != '*' and text[0] != '?' : a[0] = color + text[0] + normal if text[1] != '*' and text[1] != '?' : a[1] = color + text[1] + normal if text[2] != '*' and text[2] != '?' : a[2] = color + text[2] + normal if text[3] != '*' and text[3] != '?' : a[3] = color + text[3] + normal if text[4] != '*' and text[4] != '?' : a[4] = color + text[4] + normal text = a[0] +a[1] +a[2] +a[3] +a[4] colored_text = text return colored_text# 6432091021 sim = 72.75% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position=0 elif ch==word[1]: position=1 elif ch==word[2]: position=2 elif ch==word[3]: position=3 elif ch==word[4]: position=4 return position def check_correct_position(puzzle_word, guess_word): correct = '?'*5;new_puzzle_word = puzzle_word;new_guess_word = guess_word if puzzle_word[0] == guess_word[0]: correct=replace_kth_letter_in_str(correct, 0, guess_word[0]) new_guess_word=replace_kth_letter_in_str(new_guess_word, 0, '-') new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 0, '-') if puzzle_word[1] == guess_word[1]: correct=replace_kth_letter_in_str(correct, 1, guess_word[1]) new_guess_word=replace_kth_letter_in_str(new_guess_word, 1, '-') new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 1, '-') if puzzle_word[2] == guess_word[2]: correct=replace_kth_letter_in_str(correct, 2, guess_word[2]) new_guess_word=replace_kth_letter_in_str(guess_word, 2, '-') new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 2, '-') if puzzle_word[3] == guess_word[3]: correct=replace_kth_letter_in_str(correct, 3, guess_word[3]) new_guess_word=replace_kth_letter_in_str(new_guess_word, 3, '-') new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 3, '-') if puzzle_word[4] == guess_word[4]: correct=replace_kth_letter_in_str(correct, 4, guess_word[4]) new_guess_word=replace_kth_letter_in_str(new_guess_word, 4, '-') new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word, 4, '-') return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): original_str=original_str[:k]+ch+original_str[k+1:] return original_str def check_wrong_position(puzzle_word, guess_word): wrong_position = '*'*5 if guess_word[0] in puzzle_word and guess_word[0]!='-': xx=position_in_word(guess_word[0], puzzle_word);puzzle_word=replace_kth_letter_in_str(puzzle_word, xx,'-') wrong_position=replace_kth_letter_in_str(wrong_position,0,guess_word[0]) if guess_word[1] in puzzle_word and guess_word[1]!='-': xx=position_in_word(guess_word[1], puzzle_word);puzzle_word=replace_kth_letter_in_str(puzzle_word, xx,'-') wrong_position=replace_kth_letter_in_str(wrong_position,1,guess_word[1]) if guess_word[2] in puzzle_word and guess_word[2]!='-': xx=position_in_word(guess_word[2], puzzle_word);puzzle_word=replace_kth_letter_in_str(puzzle_word, xx,'-') wrong_position=replace_kth_letter_in_str(wrong_position,2,guess_word[2]) if guess_word[3] in puzzle_word and guess_word[3]!='-': xx=position_in_word(guess_word[3], puzzle_word);puzzle_word=replace_kth_letter_in_str(puzzle_word, xx,'-') wrong_position=replace_kth_letter_in_str(wrong_position,3,guess_word[3]) if guess_word[4] in puzzle_word and guess_word[4]!='-': xx=position_in_word(guess_word[4], puzzle_word);puzzle_word=replace_kth_letter_in_str(puzzle_word, xx,'-') wrong_position=replace_kth_letter_in_str(wrong_position,4,guess_word[4]) return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green': if text[0] !='?': colored_text= white_on_green + text[0]+ normal else: colored_text+='?' if text[1] !='?': colored_text+=(white_on_green + text[1]+ normal) else: colored_text+='?' if text[2] !='?': colored_text+=(white_on_green + text[2]+ normal) else: colored_text+='?' if text[3] !='?': colored_text+=(white_on_green + text[3]+ normal) else: colored_text+='?' if text[4] !='?': colored_text+=(white_on_green + text[4]+ normal) else: colored_text+='?' else: if text[0] !='*': colored_text= white_on_yellow + text[0]+ normal else: colored_text+='*' if text[1] !='*': colored_text+=(white_on_yellow + text[1]+ normal) else: colored_text+='*' if text[2] !='*': colored_text+=(white_on_yellow + text[2]+ normal) else: colored_text+='*' if text[3] !='*': colored_text+=(white_on_yellow + text[3]+ normal) else: colored_text+='*' if text[4] !='*': colored_text+=(white_on_yellow + text[4]+ normal) else: colored_text+='*' return colored_text# 6432168721 sim = 72.53% import random import string def position_in_word(ch, word): n = len(word) position = -1 if ch in word : if word[n-1] == ch : position = n-1 if word[n-2] == ch : position = n-2 if word[n-3] == ch : position = n-3 if word[n-4] == ch : position = n-4 if word[n-5] == ch : position = n-5 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_puzzle_word = puzzle_word new_guess_word = guess_word if puzzle_word[0] == guess_word[0] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') correct = replace_kth_letter_in_str(correct, 0, puzzle_word[0]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') if puzzle_word[1] == guess_word[1] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 1 ,'-') correct = replace_kth_letter_in_str(correct, 1, puzzle_word[1]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') if puzzle_word[2] == guess_word[2] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') correct = replace_kth_letter_in_str(correct, 2, puzzle_word[2]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') if puzzle_word[3] == guess_word[3] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') correct = replace_kth_letter_in_str(correct, 3, puzzle_word[3]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') if puzzle_word[4] == guess_word[4] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') correct = replace_kth_letter_in_str(correct, 4, puzzle_word[4]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): original_str = original_str[:k] + ch + original_str[k+1:] return original_str def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != '-' : wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), '-') else : wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != '-' : wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), '-') else : wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != '-' : wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), '-') else : wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != '-' : wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), '-') else : wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != '-' : wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), '-') else : wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'yellow' : color = white_on_yellow if color == 'green' : color = white_on_green if text[0] not in '*?': colored_text += color + text[0] + normal else : colored_text += text[0] if text[1] not in '*?': colored_text += color + text[1] + normal else : colored_text += text[1] if text[2] not in '*?': colored_text += color + text[2] + normal else : colored_text += text[2] if text[3] not in '*?': colored_text += color + text[3] + normal else : colored_text += text[3] if text[4] not in '*?': colored_text += color + text[4] + normal else : colored_text += text[4] return colored_text# 6430177021 sim = 72.47% import random import string def position_in_word(ch, word): position = -1 if word[0]==ch: position=0 if word[1]==ch: position=1 if word[2]==ch: position=2 if word[3]==ch: position=3 if word[4]==ch: position=4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_puzzle_word = puzzle_word new_guess_word = guess_word if puzzle_word[0]==guess_word[0]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') correct = replace_kth_letter_in_str(correct, 0, guess_word[0]) if puzzle_word[1]==guess_word[1]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') correct = replace_kth_letter_in_str(correct, 1, guess_word[1]) if puzzle_word[2]==guess_word[2]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') correct = replace_kth_letter_in_str(correct, 2, guess_word[2]) if puzzle_word[3]==guess_word[3]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') correct = replace_kth_letter_in_str(correct, 3, guess_word[3]) if puzzle_word[4]==guess_word[4]: new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') correct = replace_kth_letter_in_str(correct, 4, guess_word[4]) return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): if k==0: original_str=ch+original_str[1:] elif k==1: original_str=original_str[:1]+ch+original_str[2:] elif k==2: original_str=original_str[:2]+ch+original_str[3:] elif k==3: original_str=original_str[:3]+ch+original_str[4:] elif k==4: original_str=original_str[:4]+ch return original_str def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0]=='-': guess_word = replace_kth_letter_in_str(guess_word, 0, '*') if guess_word[1]=='-': guess_word = replace_kth_letter_in_str(guess_word, 1, '*') if guess_word[2]=='-': guess_word = replace_kth_letter_in_str(guess_word, 2, '*') if guess_word[3]=='-': guess_word = replace_kth_letter_in_str(guess_word, 3, '*') if guess_word[4]=='-': guess_word = replace_kth_letter_in_str(guess_word, 4, '*') if guess_word[0] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 0, guess_word[0]) i=position_in_word(guess_word[0], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, i, '-') if guess_word[1] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 1, guess_word[1]) i=position_in_word(guess_word[1], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, i, '-') if guess_word[2] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 2, guess_word[2]) i=position_in_word(guess_word[2], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, i, '-') if guess_word[3] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 3, guess_word[3]) i=position_in_word(guess_word[3], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, i, '-') if guess_word[4] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 4, guess_word[4]) i=position_in_word(guess_word[4], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, i, '-') return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text='' if color == 'green': if text[0]!='?': colored_text += white_on_green+text[0]+normal else: colored_text += text[0] if text[1]!='?': colored_text += white_on_green+text[1]+normal else: colored_text += text[1] if text[2]!='?': colored_text += white_on_green+text[2]+normal else: colored_text += text[2] if text[3]!='?': colored_text += white_on_green+text[3]+normal else: colored_text += text[3] if text[4]!='?': colored_text += white_on_green+text[4]+normal else: colored_text += text[4] else: if text[0]!='*': colored_text += white_on_yellow+text[0]+normal else: colored_text += text[0] if text[1]!='*': colored_text += white_on_yellow+text[1]+normal else: colored_text += text[1] if text[2]!='*': colored_text += white_on_yellow+text[2]+normal else: colored_text += text[2] if text[3]!='*': colored_text += white_on_yellow+text[3]+normal else: colored_text += text[3] if text[4]!='*': colored_text += white_on_yellow+text[4]+normal else: colored_text += text[4] return colored_text# 6430214521 sim = 72.43% import random import string def position_in_word(ch, word): if word[0] == ch: return 0 if word[1] == ch: return 1 if word[2] == ch: return 2 if word[3] == ch: return 3 if word[4] == ch: return 4 return -1 def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_guess_word = replace_kth_letter_in_str(new_guess_word,0,"-") correct = replace_kth_letter_in_str(correct,0,guess_word[0]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,0,"-") if guess_word[1] == puzzle_word[1]: new_guess_word = replace_kth_letter_in_str(new_guess_word,1,"-") correct = replace_kth_letter_in_str(correct,1,guess_word[1]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,1,"-") if guess_word[2] == puzzle_word[2]: new_guess_word = replace_kth_letter_in_str(new_guess_word,2,"-") correct = replace_kth_letter_in_str(correct,2,guess_word[2]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,2,"-") if guess_word[3] == puzzle_word[3]: new_guess_word = replace_kth_letter_in_str(new_guess_word,3,"-") correct = replace_kth_letter_in_str(correct,3,guess_word[3]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,3,"-") if guess_word[4] == puzzle_word[4]: new_guess_word = replace_kth_letter_in_str(new_guess_word,4,"-") correct = replace_kth_letter_in_str(correct,4,guess_word[4]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,4,"-") return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): if k == 0: return ch + original_str[1::] if k == 1: return original_str[0] + ch + original_str[2::] if k == 2: return original_str[:2:] + ch + original_str[3::] if k == 3: return original_str[:3:] + ch + original_str[4] if k == 4: return original_str[:4:] + ch def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] in puzzle_word and "-" != guess_word[0]: puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0],puzzle_word),"/") wrong_position = replace_kth_letter_in_str(wrong_position,0,guess_word[0]) if guess_word[1] in puzzle_word and "-" != guess_word[1]: puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[1],puzzle_word),"/") wrong_position = replace_kth_letter_in_str(wrong_position,1,guess_word[1]) if guess_word[2] in puzzle_word and "-" != guess_word[2]: puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[2],puzzle_word),"/") wrong_position = replace_kth_letter_in_str(wrong_position,2,guess_word[2]) if guess_word[3] in puzzle_word and "-" != guess_word[3]: puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[3],puzzle_word),"/") wrong_position = replace_kth_letter_in_str(wrong_position,3,guess_word[3]) if guess_word[4] in puzzle_word and "-" != guess_word[4]: puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[4],puzzle_word),"/") wrong_position = replace_kth_letter_in_str(wrong_position,4,guess_word[4]) return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == "green": p = white_on_green else: p = white_on_yellow x = "" if text[0] != "*" and text[0] != "?": x += p + text[0] + normal else: x += text[0] if text[1] != "*" and text[1] != "?": x += p + text[1] + normal else: x += text[1] if text[2] != "*" and text[2] != "?": x += p + text[2] + normal else: x += text[2] if text[3] != "*" and text[3] != "?": x += p + text[3] + normal else: x += text[3] if text[4] != "*" and text[4] != "?": x += p + text[4] + normal else: x += text[4] return x colored_text = text return colored_text# 6432088121 sim = 72.15% import random import string def position_in_word(ch, word): position = -1 if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') correct += guess_word[0] else : correct += '?' if guess_word[1] == puzzle_word[1] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') correct += guess_word[1] else : correct += '?' if guess_word[2] == puzzle_word[2] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') correct += guess_word[2] else : correct += '?' if guess_word[3] == puzzle_word[3] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') correct += guess_word[3] else : correct += '?' if guess_word[4] == puzzle_word[4] : new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') correct += guess_word[4] else : correct += '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): if k == 0 : m1 = ch+original_str[1:] elif k == 1 : m1 = original_str[0]+ch+original_str[2:] elif k == 2 : m1 = original_str[0:2]+ch+original_str[3:] elif k == 3 : m1 = original_str[0:3]+ch+original_str[4:] elif k == 4 : m1 = original_str[0:4]+ch return m1 def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and 'A' <= guess_word[0] <= 'Z' : n1 = position_in_word(guess_word[0], puzzle_word) wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, n1, '-') else : wrong_position += '*' if guess_word[1] in puzzle_word and 'A' <= guess_word[1] <= 'Z' : n1 = position_in_word(guess_word[1], puzzle_word) wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, n1, '-') else : wrong_position += '*' if guess_word[2] in puzzle_word and 'A' <= guess_word[2] <= 'Z' : n1 = position_in_word(guess_word[2], puzzle_word) wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, n1, '-') else : wrong_position += '*' if guess_word[3] in puzzle_word and 'A' <= guess_word[3] <= 'Z' : n1 = position_in_word(guess_word[3], puzzle_word) wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, n1, '-') else : wrong_position += '*' if guess_word[4] in puzzle_word and 'A' <= guess_word[4] <= 'Z' : n1 = position_in_word(guess_word[4], puzzle_word) wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, n1, '-') else : wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == 'green' : if 'A' <= text[0] <= 'Z' : ch1 = white_on_green + text[0] + normal else : ch1 = text[0] if 'A' <= text[1] <= 'Z' : ch2 = white_on_green + text[1] + normal else : ch2 = text[1] if 'A' <= text[2] <= 'Z' : ch3 = white_on_green + text[2] + normal else : ch3 = text[2] if 'A' <= text[3] <= 'Z' : ch4 = white_on_green + text[3] + normal else : ch4 = text[3] if 'A' <= text[4] <= 'Z' : ch5 = white_on_green + text[4] + normal else : ch5 = text[4] if color == 'yellow' : if 'A' <= text[0] <= 'Z' : ch1 = white_on_yellow + text[0] + normal else : ch1 = text[0] if 'A' <= text[1] <= 'Z' : ch2 = white_on_yellow + text[1] + normal else : ch2 = text[1] if 'A' <= text[2] <= 'Z' : ch3 = white_on_yellow + text[2] + normal else : ch3 = text[2] if 'A' <= text[3] <= 'Z' : ch4 = white_on_yellow + text[3] + normal else : ch4 = text[3] if 'A' <= text[4] <= 'Z' : ch5 = white_on_yellow + text[4] + normal else : ch5 = text[4] text = ch1+ch2+ch3+ch4+ch5 colored_text = text return colored_text# 6430315221 sim = 72.05% import random import string def position_in_word(ch, word): position = -1 if ch==word[0]: position=0 elif ch==word[1]: position=1 elif ch==word[2]: position=2 elif ch==word[3]: position=3 elif ch==word[4]: position=4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' correct = '?'*5 new_puzzle_word = puzzle_word if guess_word[0]==puzzle_word[0]: new_guess_word=replace_kth_letter_in_str(new_guess_word,0,'-') new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word,0,'-') correct=replace_kth_letter_in_str(correct,0,guess_word[0]) if guess_word[1]==puzzle_word[1]: new_guess_word=replace_kth_letter_in_str(new_guess_word,1,'-') new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word,1,'-') correct=replace_kth_letter_in_str(correct,1,guess_word[1]) if guess_word[2]==puzzle_word[2]: new_guess_word=replace_kth_letter_in_str(new_guess_word,2,'-') new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word,2,'-') correct=replace_kth_letter_in_str(correct,2,guess_word[2]) if guess_word[3]==puzzle_word[3]: new_guess_word=replace_kth_letter_in_str(new_guess_word,3,'-') new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word,3,'-') correct=replace_kth_letter_in_str(correct,3,guess_word[3]) if guess_word[4]==puzzle_word[4]: new_guess_word=replace_kth_letter_in_str(new_guess_word,4,'-') new_puzzle_word=replace_kth_letter_in_str(new_puzzle_word,4,'-') correct=replace_kth_letter_in_str(correct,4,guess_word[4]) return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): nstr=original_str[:k]+ch+original_str[k+1:] return nstr def check_wrong_position(puzzle_word, guess_word): wrong_position = '' wrong_position = '*'*5 if not position_in_word(guess_word[0],puzzle_word) in [-1,0] and guess_word[0]!='-': wrong_position=replace_kth_letter_in_str(wrong_position,0,guess_word[0]) puzzle_word=replace_letter(puzzle_word,guess_word[0],'x') if not position_in_word(guess_word[1],puzzle_word) in [-1,1] and guess_word[1]!='-': wrong_position=replace_kth_letter_in_str(wrong_position,1,guess_word[1]) puzzle_word=replace_letter(puzzle_word,guess_word[1],'x') if not position_in_word(guess_word[2],puzzle_word) in [-1,2] and guess_word[2]!='-': wrong_position=replace_kth_letter_in_str(wrong_position,2,guess_word[2]) puzzle_word=replace_letter(puzzle_word,guess_word[2],'x') if not position_in_word(guess_word[3],puzzle_word) in [-1,3] and guess_word[3]!='-': wrong_position=replace_kth_letter_in_str(wrong_position,3,guess_word[3]) puzzle_word=replace_letter(puzzle_word,guess_word[3],'x') if not position_in_word(guess_word[4],puzzle_word) in [-1,4] and guess_word[4]!='-': wrong_position=replace_kth_letter_in_str(wrong_position,4,guess_word[4]) return wrong_position def replace_letter(original, old_letter, new_letter): if old_letter in original: k = original.find(old_letter) original = original[:k] + new_letter + original[k+1:] return original def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text colored_text = '' e=['?','*','-'] if color=='green': if not text[0] in e: colored_text+=white_on_green+text[0]+normal else: colored_text+=text[0] if not text[1] in e: colored_text+=white_on_green+text[1]+normal else: colored_text+=text[1] if not text[2] in e: colored_text+=white_on_green+text[2]+normal else: colored_text+=text[2] if not text[3] in e: colored_text+=white_on_green+text[3]+normal else: colored_text+=text[3] if not text[4] in e: colored_text+=white_on_green+text[4]+normal else: colored_text+=text[4] return colored_text elif color=='yellow': if not text[0] in e: colored_text+=white_on_yellow+text[0]+normal else: colored_text+=text[0] if not text[1] in e: colored_text+=white_on_yellow+text[1]+normal else: colored_text+=text[1] if not text[2] in e: colored_text+=white_on_yellow+text[2]+normal else: colored_text+=text[2] if not text[3] in e: colored_text+=white_on_yellow+text[3]+normal else: colored_text+=text[3] if not text[4] in e: colored_text+=white_on_yellow+text[4]+normal else: colored_text+=text[4] return colored_text else: colored_text=text return colored_text# 6430202021 sim = 71.9% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' if puzzle_word[0] == guess_word[0]: guess_word = replace_kth_letter_in_str(guess_word,0,"-") correct = replace_kth_letter_in_str(correct,0,puzzle_word[0]) puzzle_word = replace_kth_letter_in_str(puzzle_word,0,"-") if puzzle_word[1] == guess_word[1]: guess_word = replace_kth_letter_in_str(guess_word,1,"-") correct = replace_kth_letter_in_str(correct,1,puzzle_word[1]) puzzle_word = replace_kth_letter_in_str(puzzle_word,1,"-") if puzzle_word[2] == guess_word[2]: guess_word = replace_kth_letter_in_str(guess_word,2,"-") correct = replace_kth_letter_in_str(correct,2,puzzle_word[2]) puzzle_word = replace_kth_letter_in_str(puzzle_word,2,"-") if puzzle_word[3] == guess_word[3]: guess_word = replace_kth_letter_in_str(guess_word,3,"-") correct = replace_kth_letter_in_str(correct,3,puzzle_word[3]) puzzle_word = replace_kth_letter_in_str(puzzle_word,3,"-") if puzzle_word[4] == guess_word[4]: guess_word = replace_kth_letter_in_str(guess_word,4,"-") correct = replace_kth_letter_in_str(correct,4,puzzle_word[4]) puzzle_word = replace_kth_letter_in_str(puzzle_word,4,"-") new_guess_word = guess_word new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] == "-": wrong_position += "*" elif guess_word[0] != "-": k = position_in_word(guess_word[0],puzzle_word) if k != -1: wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,k,"-") else: wrong_position += "*" if guess_word[1] == "-": wrong_position += "*" elif guess_word[1] != "-": k = position_in_word(guess_word[1],puzzle_word) if k != -1: wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word,k,"-") else: wrong_position += "*" if guess_word[2] == "-": wrong_position += "*" elif guess_word[2] != "-": k = position_in_word(guess_word[2],puzzle_word) if k != -1: wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word,k,"-") else: wrong_position += "*" if guess_word[3] == "-": wrong_position += "*" elif guess_word[3] != "-": k = position_in_word(guess_word[3],puzzle_word) if k != -1: wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word,k,"-") else: wrong_position += "*" if guess_word[4] == "-": wrong_position += "*" elif guess_word[4] != "-": k = position_in_word(guess_word[4],puzzle_word) if k != -1: wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word,k,"-") else: wrong_position += "*" return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == "green": color = white_on_green elif color == "yellow": color = white_on_yellow colored_text = '' if "A" <= text[0] <= "Z": colored_text += color + text[0] + normal else: colored_text += text[0] if "A" <= text[1] <= "Z": colored_text += color + text[1] + normal else: colored_text += text[1] if "A" <= text[2] <= "Z": colored_text += color + text[2] + normal else: colored_text += text[2] if "A" <= text[3] <= "Z": colored_text += color + text[3] + normal else: colored_text += text[3] if "A" <= text[4] <= "Z": colored_text += color + text[4] + normal else: colored_text += text[4] if colored_text == text: return text else: return colored_text# 6430411821 sim = 70.29% import random import string def position_in_word(ch, word): position = -1 if word[0]==ch: position=0 elif word[1]==ch: position=1 elif word[2]==ch: position=2 elif word[3]==ch: position=3 elif word[4]==ch: position=4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' i=0 if puzzle_word[i]==guess_word[i]: correct=replace_kth_letter_in_str(correct, i, puzzle_word[i]) puzzle_word=replace_kth_letter_in_str(puzzle_word, i, '-') guess_word=replace_kth_letter_in_str(guess_word, i, '-') i+=1 if puzzle_word[i]==guess_word[i]: correct=replace_kth_letter_in_str(correct, i, puzzle_word[i]) puzzle_word=replace_kth_letter_in_str(puzzle_word, i, '-') guess_word=replace_kth_letter_in_str(guess_word, i, '-') i+=1 if puzzle_word[i]==guess_word[i]: correct=replace_kth_letter_in_str(correct, i, puzzle_word[i]) puzzle_word=replace_kth_letter_in_str(puzzle_word, i, '-') guess_word=replace_kth_letter_in_str(guess_word, i, '-') i+=1 if puzzle_word[i]==guess_word[i]: correct=replace_kth_letter_in_str(correct, i, puzzle_word[i]) puzzle_word=replace_kth_letter_in_str(puzzle_word, i, '-') guess_word=replace_kth_letter_in_str(guess_word, i, '-') i+=1 if puzzle_word[i]==guess_word[i]: correct=replace_kth_letter_in_str(correct, i, puzzle_word[i]) puzzle_word=replace_kth_letter_in_str(puzzle_word, i, '-') guess_word=replace_kth_letter_in_str(guess_word, i, '-') new_guess_word=guess_word new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k]+ch+original_str[k+1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' i=0 if guess_word[i]!='-' and guess_word[i] in puzzle_word: wrong_position=replace_kth_letter_in_str(wrong_position, i, guess_word[i]) puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[i], puzzle_word), '-') i+=1 if guess_word[i]!='-' and guess_word[i] in puzzle_word: wrong_position=replace_kth_letter_in_str(wrong_position, i, guess_word[i]) puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[i], puzzle_word), '-') i+=1 if guess_word[i]!='-' and guess_word[i] in puzzle_word: wrong_position=replace_kth_letter_in_str(wrong_position, i, guess_word[i]) puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[i], puzzle_word), '-') i+=1 if guess_word[i]!='-' and guess_word[i] in puzzle_word: wrong_position=replace_kth_letter_in_str(wrong_position, i, guess_word[i]) puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[i], puzzle_word), '-') i+=1 if guess_word[i]!='-' and guess_word[i] in puzzle_word: wrong_position=replace_kth_letter_in_str(wrong_position, i, guess_word[i]) puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[i], puzzle_word), '-') return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' c="?*" colored_text = '' i=0 if color=='yellow' and not text[i] in c: colored_text=colored_text+white_on_yellow + text[i] + normal elif color=='green'and not text[i] in c: colored_text=colored_text+white_on_green + text[i] + normal else: colored_text=colored_text+text[i] i+=1 if color=='yellow'and not text[i] in c: colored_text=colored_text+white_on_yellow + text[i] + normal elif color=='green'and not text[i] in c: colored_text=colored_text+white_on_green + text[i] + normal else: colored_text=colored_text+text[i] i+=1 if color=='yellow'and not text[i] in c: colored_text=colored_text+white_on_yellow + text[i] + normal elif color=='green'and not text[i] in c: colored_text=colored_text+white_on_green + text[i] + normal else: colored_text=colored_text+text[i] i+=1 if color=='yellow'and not text[i] in c: colored_text=colored_text+white_on_yellow + text[i] + normal elif color=='green'and not text[i] in c: colored_text=colored_text+white_on_green + text[i] + normal else: colored_text=colored_text+text[i] i+=1 if color=='yellow'and not text[i] in c: colored_text=colored_text+white_on_yellow + text[i] + normal elif color=='green'and not text[i] in c: colored_text=colored_text+white_on_green + text[i] + normal else: colored_text=colored_text+text[i] return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #5(23)

# 6430162521 sim = 88.98% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_puzzle_word = '-' + puzzle_word[1:5] new_guess_word = '-' + guess_word[1:5] correct += guess_word[0] else: correct += '?' if guess_word[1] == puzzle_word[1]: new_puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:5] new_guess_word = guess_word[0] + '-' + guess_word[2:5] correct += guess_word[1] else: correct += '?' if guess_word[2] == puzzle_word[2]: new_puzzle_word = puzzle_word[0:2] + '-' + puzzle_word[3:5] new_guess_word = guess_word[0:2] + '-' + guess_word[3:5] correct += guess_word[2] else: correct += '?' if guess_word[3] == puzzle_word[3]: new_puzzle_word = puzzle_word[0:3] + '-' + puzzle_word[4] new_guess_word = guess_word[0:3] + '-' + guess_word[4] correct += guess_word[3] else: correct += '?' if guess_word[4] == puzzle_word[4]: new_puzzle_word = puzzle_word[0:4] + '-' new_guess_word = guess_word[0:4] + '-' correct += guess_word[4] else: correct += '?' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0]: wrong_position += guess_word[0] if guess_word[0] == puzzle_word[1]: puzzle_word = puzzle_word[0] + '_' + puzzle_word[2:5] if guess_word[0] == puzzle_word[2]: puzzle_word = puzzle_word[0:2] + '_' + puzzle_word[3:5] if guess_word[0] == puzzle_word[3]: puzzle_word = puzzle_word[0:3] + '_' + puzzle_word[4] if guess_word[0] == puzzle_word[4]: puzzle_word = puzzle_word[0:4] + '_' else: wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: wrong_position += guess_word[1] if guess_word[1] == puzzle_word[0]: puzzle_word = '_' + puzzle_word[1:5] if guess_word[1] == puzzle_word[2]: puzzle_word = puzzle_word[0:2] + '_' + puzzle_word[3:5] if guess_word[1] == puzzle_word[3]: puzzle_word = puzzle_word[0:3] + '_' + puzzle_word[4] if guess_word[1] == puzzle_word[4]: puzzle_word = puzzle_word[0:4] + '_' else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: wrong_position += guess_word[2] if guess_word[2] == puzzle_word[1]: puzzle_word = puzzle_word[0] + '_' + puzzle_word[2:5] if guess_word[2] == puzzle_word[0]: puzzle_word = '_' + puzzle_word[1:5] if guess_word[2] == puzzle_word[3]: puzzle_word = puzzle_word[0:3] + '_' + puzzle_word[4] if guess_word[2] == puzzle_word[4]: puzzle_word = puzzle_word[0:4] + '_' else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: wrong_position += guess_word[3] if guess_word[3] == puzzle_word[1]: puzzle_word = puzzle_word[0] + '_' + puzzle_word[2:5] if guess_word[3] == puzzle_word[2]: puzzle_word = puzzle_word[0:2] + '_' + puzzle_word[3:5] if guess_word[3] == puzzle_word[0]: puzzle_word = '_' + puzzle_word[1:5] if guess_word[3] == puzzle_word[4]: puzzle_word = puzzle_word[0:4] + '_' else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: wrong_position += guess_word[4] if guess_word[4] == puzzle_word[1]: puzzle_word = puzzle_word[0] + '_' + puzzle_word[2:5] if guess_word[4] == puzzle_word[2]: puzzle_word = puzzle_word[0:2] + '_' + puzzle_word[3:5] if guess_word[4] == puzzle_word[3]: puzzle_word = puzzle_word[0:3] + '_' + puzzle_word[4] if guess_word[4] == puzzle_word[0]: puzzle_word = '_' + puzzle_word[1:5] else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0: original_str = ch + original_str[1:5] if k == 1: original_str = original_str[0] + ch + original_str[2:5] if k == 2: original_str = original_str[0:2] + ch + original_str[3:5] if k == 3: original_str = original_str[0:3] + ch + original_str[4] if k == 4: original_str = original_str[0:4] + ch return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text[0] == '?' or text[0] == '*': colored_text += text[0] elif color == 'green': colored_text += white_on_green + text[0] + normal elif color == 'yellow': colored_text += white_on_yellow + text[0] + normal if text[1] == '?' or text[1] == '*': colored_text += text[1] elif color == 'green': colored_text += white_on_green + text[1] + normal elif color == 'yellow': colored_text += white_on_yellow + text[1] + normal if text[2] == '?' or text[2] == '*': colored_text += text[2] elif color == 'green': colored_text += white_on_green + text[2] + normal elif color == 'yellow': colored_text += white_on_yellow + text[2] + normal if text[3] == '?' or text[3] == '*': colored_text += text[3] elif color == 'green': colored_text += white_on_green + text[3] + normal elif color == 'yellow': colored_text += white_on_yellow + text[3] + normal if text[4] == '?' or text[4] == '*': colored_text += text[4] elif color == 'green': colored_text += white_on_green + text[4] + normal elif color == 'yellow': colored_text += white_on_yellow + text[4] + normal return colored_text# 6430347321 sim = 88.98% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_guess_word = '-' + guess_word[1:5] correct += guess_word[0] new_puzzle_word = '-' + puzzle_word[1:5] else: correct += '?' if guess_word[1] == puzzle_word[1]: new_guess_word += guess_word[0] + '-' + guess_word[2:5] correct += guess_word[1] new_puzzle_word += puzzle_word[0] + '-' + puzzle_word[2:5] else: correct += '?' if guess_word[2] == puzzle_word[2]: new_guess_word += guess_word[0:2] +'-' + guess_word[3:5] correct += guess_word[2] new_puzzle_word += puzzle_word[0:2] + '-' + puzzle_word [3:5] else: correct += '?' if guess_word[3] == puzzle_word[3]: new_guess_word += guess_word[0:3] + '-' + guess_word[4] correct += guess_word[3] new_puzzle_word += puzzle_word[0:3] + '-' + puzzle_word[4] else: correct += '?' if guess_word[4] == puzzle_word[4]: new_guess_word += guess_word[0:4] +'-' correct += guess_word[4] new_puzzle_word += puzzle_word[0:4] +'-' else: correct += '?' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0]: wrong_position += guess_word[0] if guess_word[0] == puzzle_word[1]: puzzle_word = puzzle_word[0] + '.' + puzzle_word[2:5] if guess_word[0] == puzzle_word[2]: puzzle_word = puzzle_word[0:2] + '.' + puzzle_word[3:5] if guess_word[0] == puzzle_word[3]: puzzle_word = puzzle_word[0:3] + '.' + puzzle_word[4:5] if guess_word[0] == puzzle_word[4]: puzzle_word = puzzle_word[0:4] + '.' else: wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: wrong_position += guess_word[1] if guess_word[1] == puzzle_word[0]: puzzle_word = '_' + puzzle_word[1:5] if guess_word[1] == puzzle_word[2]: puzzle_word = puzzle_word[0:2] + '_' + puzzle_word[3:5] if guess_word[1] == puzzle_word[3]: puzzle_word = puzzle_word[0:3] + '_' + puzzle_word[4:5] if guess_word[1] == puzzle_word[4]: puzzle_word = puzzle_word[0:4] + '_' else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: wrong_position += guess_word[2] if guess_word[2] == puzzle_word[1]: puzzle_word = puzzle_word[0] + '_' + puzzle_word[2:5] if guess_word[2] == puzzle_word[0]: puzzle_word = '_' + puzzle_word[1:5] if guess_word[2] == puzzle_word[3]: puzzle_word = puzzle_word[0:3] + '_' + puzzle_word[4] if guess_word[2] == puzzle_word[4]: puzzle_word = puzzle_word[0:4] + '_' else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: wrong_position += guess_word[3] if guess_word[3] == puzzle_word[1]: puzzle_word = puzzle_word[0] + '_' + puzzle_word[2:5] if guess_word[3] == puzzle_word[2]: puzzle_word = puzzle_word[0:2] + '_' + puzzle_word[3:5] if guess_word[3] == puzzle_word[0]: puzzle_word = '_' + puzzle_word[1:5] if guess_word[3] == puzzle_word[4]: puzzle_word = puzzle_word[0:4] + '_' else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: wrong_position += guess_word[4] if guess_word[4] == puzzle_word[1]: puzzle_word = puzzle_word[0] + '_' + puzzle_word[2:5] if guess_word[4] == puzzle_word[2]: puzzle_word = puzzle_word[0:2] + '_' + puzzle_word[3:5] if guess_word[4] == puzzle_word[3]: puzzle_word = puzzle_word[0:3] + '_' + puzzle_word[4] if guess_word[4] == puzzle_word[0]: puzzle_word = '_' + puzzle_word[1:5] else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0: original_str = ch + original_str[1:5] if k == 1: original_str = original_str[0] + ch + original_str[2:5] if k == 2: original_str = original_str[0:2] + ch + original_str[3:5] if k == 3: original_str = original_str[0:3] + ch + original_str[4:5] if k == 4: original_str = original_str[0:4] + ch return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text[0] != '?' and text[0] != '*': if color == 'green': colored_text += white_on_green + text[0] + normal if color == 'yellow': colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if text[1] != '?' and text[1] != '*': if color == 'green': colored_text += white_on_green + text[1] + normal if color == 'yellow': colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if text[2] != '?' and text[2] != '*': if color == 'green': colored_text += white_on_green + text[2] + normal if color == 'yellow': colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if text[3] != '?' and text[3] != '*': if color == 'green': colored_text += white_on_green + text[3] + normal if color == 'yellow': colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if text[4] != '?' and text[4] != '*': if color == 'green': colored_text += white_on_green + text[4] + normal if color == 'yellow': colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text# 6430253021 sim = 86.85% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position += 1 elif word[1] == ch: position += 2 elif word[2] == ch: position += 3 elif word[3] == ch: position += 4 elif word[4] == ch: position += 5 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_guess_word = "-" + new_guess_word[1:] new_puzzle_word = "-" + new_puzzle_word[1:] correct += guess_word[0] else: correct += "?" if guess_word[1] == puzzle_word[1]: new_guess_word = new_guess_word[:1] + "-" + new_guess_word[2:] new_puzzle_word = new_puzzle_word[:1] + "-" + new_puzzle_word[2:] correct += guess_word[1] else: correct += "?" if guess_word[2] == puzzle_word[2]: new_guess_word = new_guess_word[:2] + "-" + new_guess_word[3:] new_puzzle_word = new_puzzle_word[:2] + "-" + new_puzzle_word[3:] correct += guess_word[2] else: correct += "?" if guess_word[3] == puzzle_word[3]: new_guess_word = new_guess_word[:3] + "-" + new_guess_word[4:] new_puzzle_word = new_puzzle_word[:3] + "-" + new_puzzle_word[4:] correct += guess_word[3] else: correct += "?" if guess_word[4] == puzzle_word[4]: new_guess_word = new_guess_word[:4] + "-" new_puzzle_word = new_puzzle_word[:4] + "-" correct += guess_word[4] else: correct += "?" return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if "A" <= guess_word[0] <= "Z": if guess_word[0] == puzzle_word[0]: wrong_position += guess_word[0] puzzle_word = "-" + puzzle_word[1:] elif guess_word[0] == puzzle_word[1]: wrong_position += guess_word[0] puzzle_word = puzzle_word[:1] + "-" + puzzle_word[2:] elif guess_word[0] == puzzle_word[2]: wrong_position += guess_word[0] puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[0] == puzzle_word[3]: wrong_position += guess_word[0] puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4:] elif guess_word[0] == puzzle_word[4]: wrong_position += guess_word[0] puzzle_word = puzzle_word[:4] + "-" else: wrong_position += "*" else: wrong_position += "*" if "A" <= guess_word[1] <= "Z": if guess_word[1] == puzzle_word[0]: wrong_position += guess_word[1] puzzle_word = "-" + puzzle_word[1:] elif guess_word[1] == puzzle_word[1]: wrong_position += guess_word[1] puzzle_word = puzzle_word[:1] + "-" + puzzle_word[2:] elif guess_word[1] == puzzle_word[2]: wrong_position += guess_word[1] puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[1] == puzzle_word[3]: wrong_position += guess_word[1] puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4:] elif guess_word[1] == puzzle_word[4]: wrong_position += guess_word[1] puzzle_word = puzzle_word[:4] + "-" else: wrong_position += "*" else: wrong_position += "*" if "A" <= guess_word[2] <= "Z": if guess_word[2] == puzzle_word[0]: wrong_position += guess_word[2] puzzle_word = "-" + puzzle_word[1:] elif guess_word[2] == puzzle_word[1]: wrong_position += guess_word[2] puzzle_word = puzzle_word[:1] + "-" + puzzle_word[2:] elif guess_word[2] == puzzle_word[2]: wrong_position += guess_word[2] puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[2] == puzzle_word[3]: wrong_position += guess_word[2] puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4:] elif guess_word[2] == puzzle_word[4]: wrong_position += guess_word[2] puzzle_word = puzzle_word[:4] + "-" else: wrong_position += "*" else: wrong_position += "*" if "A" <= guess_word[3] <= "Z": if guess_word[3] == puzzle_word[0]: wrong_position += guess_word[3] puzzle_word = "-" + puzzle_word[1:] elif guess_word[3] == puzzle_word[1]: wrong_position += guess_word[3] puzzle_word = puzzle_word[:1] + "-" + puzzle_word[2:] elif guess_word[3] == puzzle_word[2]: wrong_position += guess_word[3] puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[3] == puzzle_word[3]: wrong_position += guess_word[3] puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4:] elif guess_word[3] == puzzle_word[4]: wrong_position += guess_word[3] puzzle_word = puzzle_word[:4] + "-" else: wrong_position += "*" else: wrong_position += "*" if "A" <= guess_word[4] <= "Z": if guess_word[4] == puzzle_word[0]: wrong_position += guess_word[4] puzzle_word = "-" + puzzle_word[1:] elif guess_word[4] == puzzle_word[1]: wrong_position += guess_word[4] puzzle_word = puzzle_word[:1] + "-" + puzzle_word[2:] elif guess_word[4] == puzzle_word[2]: wrong_position += guess_word[4] puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[4] == puzzle_word[3]: wrong_position += guess_word[4] puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4:] elif guess_word[4] == puzzle_word[4]: wrong_position += guess_word[4] puzzle_word = puzzle_word[:4] + "-" else: wrong_position += "*" else: wrong_position += "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): a = original_str[:k] + ch + original_str[k+1:] return a def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == "green": if "A" <= text[0] <= "Z": text0 = white_on_green + text[0] + normal else: text0 = text[0] if "A" <= text[1] <= "Z": text1 = white_on_green + text[1] + normal else: text1 = text[1] if "A" <= text[2] <= "Z": text2 = white_on_green + text[2] + normal else: text2 = text[2] if "A" <= text[3] <= "Z": text3 = white_on_green + text[3] + normal else: text3 = text[3] if "A" <= text[4] <= "Z": text4 = white_on_green + text[4] + normal else: text4 = text[4] colored_text = text0 + text1 + text2 + text3 + text4 elif color == "yellow": if "A" <= text[0] <= "Z": text0 = white_on_yellow + text[0] + normal else: text0 = text[0] if "A" <= text[1] <= "Z": text1 = white_on_yellow + text[1] + normal else: text1 = text[1] if "A" <= text[2] <= "Z": text2 = white_on_yellow + text[2] + normal else: text2 = text[2] if "A" <= text[3] <= "Z": text3 = white_on_yellow + text[3] + normal else: text3 = text[3] if "A" <= text[4] <= "Z": text4 = white_on_yellow + text[4] + normal else: text4 = text[4] colored_text = text0 + text1 + text2 + text3 + text4 return colored_text# 6432014721 sim = 86.85% import random import string def position_in_word(ch, word): if ch == word[0] : position = 0 if ch == word[1] : position = 1 if ch == word[2] : position = 2 if ch== word[3] : position=3 if ch==word[4] : position = 4 position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0]==puzzle_word[0] : correct += puzzle_word[0] new_guess_word = '-'+ new_guess_word[1:] new_puzzle_word = '-' + new_puzzle_word[1:] else : correct += '?' if guess_word[1]==puzzle_word[1] : correct += puzzle_word[1] new_guess_word = new_guess_word[0] + '-'+ new_guess_word[2:] new_puzzle_word = new_puzzle_word[0]+ '-' + new_puzzle_word[1:] else : correct += '?' if guess_word[2]==puzzle_word[2] : correct += puzzle_word[2] new_guess_word = new_guess_word[:2] + '-'+ new_guess_word[3:] new_puzzle_word = new_puzzle_word[:2]+ '-' + new_puzzle_word[3:] else : correct += '?' if guess_word[3]==puzzle_word[3] : correct += puzzle_word[3] new_guess_word = new_guess_word[:3] + '-'+ new_guess_word[4] new_puzzle_word = new_puzzle_word[:3]+ '-' + new_puzzle_word[4] else : correct += '?' if guess_word[4]==puzzle_word[4] : correct += puzzle_word[4] new_guess_word = new_guess_word[:4] + '-' new_puzzle_word = new_puzzle_word[:4]+ '-' else : correct += '?' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and 'A'<= guess_word[0]<= 'Z': if guess_word[0]==puzzle_word[0] : wrong_position += guess_word[0] puzzle_word= '-'+puzzle_word[1:] elif guess_word[0]==puzzle_word[1] : wrong_position += guess_word[0] puzzle_word= puzzle_word[0]+'-'+puzzle_word[2:] elif guess_word[0]==puzzle_word[2] : wrong_position += guess_word[0] puzzle_word= puzzle_word[:2]+'-'+puzzle_word[3:] elif guess_word[0]==puzzle_word[3] : wrong_position += guess_word[0] puzzle_word= puzzle_word[:3]+'-'+puzzle_word[4] elif guess_word[0]==puzzle_word[4] : wrong_position += guess_word[0] puzzle_word= puzzle_word[:4]+'-' else : wrong_position += '*' else : wrong_position += '*' if guess_word[1] in puzzle_word and 'A'<= guess_word[1]<= 'Z' : if guess_word[1]==puzzle_word[0] : wrong_position += guess_word[1] puzzle_word= '-'+puzzle_word[1:] elif guess_word[1]==puzzle_word[1] : wrong_position += guess_word[1] puzzle_word= puzzle_word[0]+'-'+puzzle_word[2:] elif guess_word[1]==puzzle_word[2] : wrong_position += guess_word[1] puzzle_word= puzzle_word[:2]+'-'+puzzle_word[3:] elif guess_word[1]==puzzle_word[3] : wrong_position += guess_word[1] puzzle_word= puzzle_word[:3]+'-'+puzzle_word[4] elif guess_word[1]==puzzle_word[4] : wrong_position += guess_word[1] puzzle_word= puzzle_word[:4]+'-' else : wrong_position += '*' else : wrong_position += '*' if guess_word[2] in puzzle_word and 'A'<= guess_word[2]<= 'Z': if guess_word[2]==puzzle_word[0] : wrong_position += guess_word[2] puzzle_word= '-'+puzzle_word[1:] elif guess_word[2]==puzzle_word[1] : wrong_position += guess_word[2] puzzle_word= puzzle_word[0]+'-'+puzzle_word[2:] elif guess_word[2]==puzzle_word[2] : wrong_position += guess_word[2] puzzle_word= puzzle_word[:2]+'-'+puzzle_word[3:] elif guess_word[2]==puzzle_word[3] : wrong_position += guess_word[2] puzzle_word= puzzle_word[:3]+'-'+puzzle_word[4] elif guess_word[2]==puzzle_word[4] : wrong_position += guess_word[2] puzzle_word= puzzle_word[:4]+'-' else : wrong_position += '*' else : wrong_position += '*' if guess_word[3] in puzzle_word and 'A'<= guess_word[3]<= 'Z': if guess_word[3]==puzzle_word[0] : wrong_position += guess_word[3] puzzle_word= '-'+puzzle_word[1:] elif guess_word[3]==puzzle_word[1] : wrong_position += guess_word[3] puzzle_word= puzzle_word[0]+'-'+puzzle_word[2:] elif guess_word[3]==puzzle_word[2] : wrong_position += guess_word[3] puzzle_word= puzzle_word[:2]+'-'+puzzle_word[3:] elif guess_word[3]==puzzle_word[3] : wrong_position += guess_word[3] puzzle_word= puzzle_word[:3]+'-'+puzzle_word[4] elif guess_word[3]==puzzle_word[4] : wrong_position += guess_word[3] puzzle_word= puzzle_word[:4]+'-' else : wrong_position += '*' else : wrong_position += '*' if guess_word[4] in puzzle_word and 'A'<= guess_word[4]<= 'Z' : if guess_word[4]==puzzle_word[0] : wrong_position += guess_word[4] puzzle_word= '-'+puzzle_word[1:] elif guess_word[4]==puzzle_word[1] : wrong_position += guess_word[4] puzzle_word= puzzle_word[0]+'-'+puzzle_word[2:] elif guess_word[4]==puzzle_word[2] : wrong_position += guess_word[4] puzzle_word= puzzle_word[:2]+'-'+puzzle_word[3:] elif guess_word[4]==puzzle_word[3] : wrong_position += guess_word[4] puzzle_word= puzzle_word[:3]+'-'+puzzle_word[4] elif guess_word[4]==puzzle_word[4] : wrong_position += guess_word[4] puzzle_word= puzzle_word[:4]+'-' else : wrong_position += '*' else : wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k==0 : x=ch + original_str[1:] if k==1 : x=original_str[0] + ch + original_str[2:] if k==2 : x=original_str[:2] + ch + original_str[3:] if k==3 : x=original_str[:3] + ch + original_str[4] if k==4 : x=original_str[:4] + ch return x def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == 'green' : if 'A'<= text[0] <= 'Z' : ch0 = white_on_green + text[0] + normal else : ch0=text[0] if 'A'<= text[1] <= 'Z' : ch1 = white_on_green + text[1] + normal else : ch1=text[1] if 'A'<= text[2] <= 'Z' : ch2 = white_on_green + text[2] + normal else : ch2=text[2] if 'A'<= text[3] <= 'Z' : ch3 = white_on_green + text[3] + normal else : ch3=text[3] if 'A'<= text[4] <= 'Z' : ch4 = white_on_green + text[4] + normal else : ch4=text[4] colored_text = ch0+ch1+ch2+ch3+ch4 if color == 'yellow' : if 'A'<= text[0] <= 'Z' : ch0 = white_on_yellow + text[0] + normal else : ch0=text[0] if 'A'<= text[1] <= 'Z' : ch1 = white_on_yellow + text[1] + normal else : ch1=text[1] if 'A'<= text[2] <= 'Z' : ch2 = white_on_yellow + text[2] + normal else : ch2=text[2] if 'A'<= text[3] <= 'Z' : ch3 = white_on_yellow + text[3] + normal else : ch3=text[3] if 'A'<= text[4] <= 'Z' : ch4 = white_on_yellow + text[4] + normal else : ch4=text[4] colored_text =ch0 + ch1 + ch2 + ch3 + ch4 return colored_text# 6430412421 sim = 80.67% import random import string def position_in_word(ch, word): if ch in word: if ch == word[0]: position=0 elif ch == word[1] : position=1 elif ch == word[2] : position=2 elif ch == word[3] : position=3 elif ch == word[4] : position=4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0]==puzzle_word[0]: new_guess_word='-'+guess_word[1:5:1] new_puzzle_word='-'+puzzle_word[1:5:1] correct=correct+guess_word[0] else: correct=correct+'?' if guess_word[1]==puzzle_word[1]: new_guess_word=guess_word[0]+'-'+guess_word[2:5:1] new_puzzle_word=puzzle_word[0]+'-'+puzzle_word[2:5:1] correct=correct+guess_word[1] else: correct=correct+'?' if guess_word[2]==puzzle_word[2]: new_guess_word=guess_word[0:2:1]+'-'+guess_word[3:5:1] new_puzzle_word=puzzle_word[0:2:1]+'-'+puzzle_word[3:5:1] correct=correct+guess_word[2] else: correct=correct+'?' if guess_word[3]==puzzle_word[3]: new_guess_word=guess_word[0:3:1]+'-'+guess_word[4] new_puzzle_word=puzzle_word[0:3:1]+'-'+puzzle_word[4] correct=correct+guess_word[3] else: correct=correct+'?' if guess_word[4]==puzzle_word[4]: new_guess_word=guess_word[0:4:1]+'-' new_puzzle_word=puzzle_word[0:4:1]+'-' correct=correct+guess_word[4] else: correct=correct+'?' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if 'A'<=guess_word[0]<='Z': if guess_word[0]==puzzle_word[0]: wrong_position=wrong_position+guess_word[0] puzzle_word='-'+puzzle_word[1:5:1] elif guess_word[0]==puzzle_word[1] : wrong_position=wrong_position+guess_word[0] puzzle_word=puzzle_word[0]+'-'+puzzle_word[2:5:1] elif guess_word[0]==puzzle_word[2] : wrong_position=wrong_position+guess_word[0] puzzle_word=puzzle_word[0:2:1]+'-'+puzzle_word[3:5:1] elif guess_word[0]==puzzle_word[3] : wrong_position=wrong_position+guess_word[0] puzzle_word=puzzle_word[0:3:1]+'-'+puzzle_word[4] elif guess_word[0]==puzzle_word[4] : wrong_position=wrong_position+guess_word[0] puzzle_word=puzzle_word[0:4:1]+'-' else: wrong_position=wrong_position+'*' else: wrong_position=wrong_position+'*' if 'A'<=guess_word[1]<='Z': if guess_word[1]==puzzle_word[0]: wrong_position=wrong_position+guess_word[1] puzzle_word='-'+puzzle_word[1:5:1] elif guess_word[1]==puzzle_word[1]: wrong_position=wrong_position+guess_word[1] puzzle_word=puzzle_word[0]+'-'+puzzle_word[2:5:1] elif guess_word[1]==puzzle_word[2]: wrong_position=wrong_position+guess_word[1] puzzle_word=puzzle_word[0:2:1]+'-'+puzzle_word[3:5:1] elif guess_word[1]==puzzle_word[3]: wrong_position=wrong_position+guess_word[1] puzzle_word=puzzle_word[0:3:1]+'-'+puzzle_word[4] elif guess_word[1]==puzzle_word[4]: wrong_position=wrong_position+guess_word[1] puzzle_word=puzzle_word[0:4:1]+'-' else: wrong_position=wrong_position+'*' else: wrong_position=wrong_position+'*' if'A'<=guess_word[2]<='Z': if guess_word[2]==puzzle_word[0]: wrong_position=wrong_position+guess_word[2] puzzle_word='-'+puzzle_word[1:5:1] elif guess_word[2]==puzzle_word[1]: wrong_position=wrong_position+guess_word[2] puzzle_word=puzzle_word[0]+'-'+puzzle_word[2:5:1] elif guess_word[2]==puzzle_word[2]: wrong_position=wrong_position+guess_word[2] puzzle_word=puzzle_word[0:2:1]+'-'+puzzle_word[3:5:1] elif guess_word[2]==puzzle_word[3]: wrong_position=wrong_position+guess_word[2] puzzle_word=puzzle_word[0:3:1]+'-'+puzzle_word[4] elif guess_word[2]==puzzle_word[4]: wrong_position=wrong_position+guess_word[2] puzzle_word=puzzle_word[0:4:1]+'-' else: wrong_position=wrong_position+'*' else: wrong_position=wrong_position+'*' if'A'<=guess_word[3]<='Z': if guess_word[3]==puzzle_word[0]: wrong_position=wrong_position+guess_word[3] puzzle_word='-'+puzzle_word[1:5:1] elif guess_word[3]==puzzle_word[1]: wrong_position=wrong_position+guess_word[3] puzzle_word=puzzle_word[0]+'-'+puzzle_word[2:5:1] elif guess_word[3]==puzzle_word[2]: wrong_position=wrong_position+guess_word[3] puzzle_word=puzzle_word[0:2:1]+'-'+puzzle_word[3:5:1] elif guess_word[3]==puzzle_word[3]: wrong_position=wrong_position+guess_word[3] puzzle_word=puzzle_word[0:3:1]+'-'+puzzle_word[4] elif guess_word[3]==puzzle_word[4]: wrong_position=wrong_position+guess_word[3] puzzle_word=puzzle_word[0:4:1]+'-' else: wrong_position=wrong_position+'*' else: wrong_position=wrong_position+'*' if'A'<=guess_word[4]<='Z': if guess_word[4]==puzzle_word[0]: wrong_position=wrong_position+guess_word[4] puzzle_word='-'+puzzle_word[1:5:1] elif guess_word[4]==puzzle_word[1]: wrong_position=wrong_position+guess_word[4] puzzle_word=puzzle_word[0]+'-'+puzzle_word[2:5:1] elif guess_word[4]==puzzle_word[2]: wrong_position=wrong_position+guess_word[4] puzzle_word=puzzle_word[0:2:1]+'-'+puzzle_word[3:5:1] elif guess_word[4]==puzzle_word[3]: wrong_position=wrong_position+guess_word[4] puzzle_word=puzzle_word[0:3:1]+'-'+puzzle_word[4] elif guess_word[4]==puzzle_word[4]: wrong_position=wrong_position+guess_word[4] puzzle_word=puzzle_word[0:4:1]+'-' else: wrong_position=wrong_position+'*' else: wrong_position=wrong_position+'*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[0:k:1] + ch + original_str[k+1:] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color=='green': if 'A'<=text[0]<='Z': t0=white_on_green+text[0]+normal else: t0=text[0] if 'A'<=text[1]<='Z': t1=white_on_green+text[1]+normal else: t1=text[1] if 'A'<=text[2]<='Z': t2=white_on_green+text[2]+normal else: t2=text[2] if 'A'<=text[3]<='Z': t3=white_on_green+text[3]+normal else: t3=text[3] if 'A'<=text[4]<='Z': t4=white_on_green+text[4]+normal else: t4=text[4] elif color=='yellow': if 'A'<=text[0]<='Z': t0=white_on_yellow+text[0]+normal else: t0=text[0] if 'A'<=text[1]<='Z': t1=white_on_yellow+text[1]+normal else: t1=text[1] if 'A'<=text[2]<='Z': t2=white_on_yellow+text[2]+normal else: t2=text[2] if 'A'<=text[3]<='Z': t3=white_on_yellow+text[3]+normal else: t3=text[3] if 'A'<=text[4]<='Z': t4=white_on_yellow+text[4]+normal else: t4=text[4] colored_text=t0+t1+t2+t3+t4 return colored_text# 6430356021 sim = 80.08% import random import string def position_in_word(ch, word): position = -1 if ch in word : if ch == word[0]:position=0 elif ch == word[1]:position=1 elif ch == word[2]:position=2 elif ch == word[3]:position=3 elif ch == word[4]:position=4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_puzzle_word = puzzle_word new_guess_word=guess_word if guess_word[0] == puzzle_word[0]: correct = guess_word[0] + correct[1::] new_puzzle_word = "-" + new_puzzle_word[1::] new_guess_word ="-"+new_guess_word[1::] if guess_word[1] == puzzle_word[1]: correct = correct[0] + guess_word[1] + correct[2::] new_puzzle_word = new_puzzle_word[0] + "-" + new_puzzle_word[2::] new_guess_word = new_guess_word[0] + "-" + new_guess_word[2::] if guess_word[2] == puzzle_word[2]: correct = correct[0:2] + guess_word[2] + correct[3::] new_puzzle_word = new_puzzle_word[0:2] + "-" + new_puzzle_word[3::] new_guess_word = new_guess_word[0:2] + "-" + new_guess_word[3::] if guess_word[3] == puzzle_word[3]: correct = correct[0:3] + guess_word[3] + correct[4] new_puzzle_word = new_puzzle_word[0:3] + "-" + new_puzzle_word[4] new_guess_word = new_guess_word[0:3] + "-" + new_guess_word[4] if guess_word[4] == puzzle_word[4]: correct = correct[0:4] + guess_word[4] new_puzzle_word = new_puzzle_word[0:4] + "-" new_guess_word = new_guess_word[0:4] + "-" return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' updated_puzzle_word=puzzle_word if guess_word[0] in updated_puzzle_word : if guess_word[0]==updated_puzzle_word[0]: updated_puzzle_word="#"+updated_puzzle_word[1::] elif guess_word[0]==updated_puzzle_word[1]: wrong_position=guess_word[0]+wrong_position[1::] updated_puzzle_word=updated_puzzle_word[0]+"#"+updated_puzzle_word[2::] elif guess_word[0]==updated_puzzle_word[2]: wrong_position=guess_word[0]+wrong_position[1::] updated_puzzle_word=updated_puzzle_word[0:2]+"#"+updated_puzzle_word[3::] elif guess_word[0]==updated_puzzle_word[3]: wrong_position=guess_word[0]+wrong_position[1::] updated_puzzle_word=updated_puzzle_word[0:3]+"#"+updated_puzzle_word[4::] elif guess_word[0]==updated_puzzle_word[4]: wrong_position=guess_word[0]+wrong_position[1::] updated_puzzle_word=updated_puzzle_word[0:4]+"#" if guess_word[1] in updated_puzzle_word : if guess_word[1]==updated_puzzle_word[0]: wrong_position=wrong_position[0]+guess_word[1]+wrong_position[2::] updated_puzzle_word="#"+updated_puzzle_word[1::] elif guess_word[1]==updated_puzzle_word[1]: updated_puzzle_word=updated_puzzle_word[0]+"#"+updated_puzzle_word[2::] elif guess_word[1]==updated_puzzle_word[2]: wrong_position=wrong_position[0]+guess_word[1]+wrong_position[2::] updated_puzzle_word=updated_puzzle_word[0:2]+"#"+updated_puzzle_word[3::] elif guess_word[1]==updated_puzzle_word[3]: wrong_position=wrong_position[0]+guess_word[1]+wrong_position[2::] updated_puzzle_word=updated_puzzle_word[0:3]+"#"+updated_puzzle_word[4::] elif guess_word[1]==updated_puzzle_word[4]: wrong_position=wrong_position[0]+guess_word[1]+wrong_position[2::] updated_puzzle_word=updated_puzzle_word[0:4]+"#" if guess_word[2] in updated_puzzle_word : if guess_word[2]==updated_puzzle_word[0]: wrong_position=wrong_position[0:2]+guess_word[2]+wrong_position[3::] updated_puzzle_word="#"+updated_puzzle_word[1::] elif guess_word[2]==updated_puzzle_word[1]: wrong_position=wrong_position[0:2]+guess_word[2]+wrong_position[3::] updated_puzzle_word=updated_puzzle_word[0]+"#"+updated_puzzle_word[2::] elif guess_word[2]==updated_puzzle_word[2]: updated_puzzle_word=updated_puzzle_word[0:2]+"#"+updated_puzzle_word[3::] elif guess_word[2]==updated_puzzle_word[3]: wrong_position=wrong_position[0:2]+guess_word[2]+wrong_position[3::] updated_puzzle_word=updated_puzzle_word[0:3]+"#"+updated_puzzle_word[4::] elif guess_word[2]==updated_puzzle_word[4]: wrong_position=wrong_position[0:2]+guess_word[2]+wrong_position[3::] updated_puzzle_word=updated_puzzle_word[0:4]+"#" if guess_word[3] in updated_puzzle_word : if guess_word[3]==updated_puzzle_word[0]: wrong_position=wrong_position[0:3]+guess_word[3]+wrong_position[4] updated_puzzle_word="#"+updated_puzzle_word[1::] elif guess_word[3]==updated_puzzle_word[1]: wrong_position=wrong_position[0:3]+guess_word[3]+wrong_position[4] updated_puzzle_word=updated_puzzle_word[0]+"#"+updated_puzzle_word[2::] elif guess_word[3]==updated_puzzle_word[2]: wrong_position=wrong_position[0:3]+guess_word[3]+wrong_position[4] updated_puzzle_word=updated_puzzle_word[0:2]+"#"+updated_puzzle_word[3::] elif guess_word[3]==updated_puzzle_word[3]: updated_puzzle_word=updated_puzzle_word[0:3]+"#"+updated_puzzle_word[4::] elif guess_word[3]==updated_puzzle_word[4]: wrong_position=wrong_position[0:3]+guess_word[3]+wrong_position[4] updated_puzzle_word=updated_puzzle_word[0:4]+"#" if guess_word[4] in updated_puzzle_word : if guess_word[4]==updated_puzzle_word[0]: wrong_position=wrong_position[0:4]+guess_word[4] updated_puzzle_word="#"+updated_puzzle_word[1::] elif guess_word[4]==updated_puzzle_word[1]: wrong_position=wrong_position[0:4]+guess_word[4] updated_puzzle_word=updated_puzzle_word[0]+"#"+updated_puzzle_word[2::] elif guess_word[4]==updated_puzzle_word[2]: wrong_position=wrong_position[0:4]+guess_word[4] updated_puzzle_word=updated_puzzle_word[0:2]+"#"+updated_puzzle_word[3::] elif guess_word[4]==updated_puzzle_word[3]: wrong_position=wrong_position[0:4]+guess_word[4] updated_puzzle_word=updated_puzzle_word[0:3]+"#"+updated_puzzle_word[4::] elif guess_word[4]==updated_puzzle_word[4]: updated_puzzle_word=updated_puzzle_word[0:4]+"#" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): new_str=original_str[:k]+ch+original_str[k+1::] return new_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == "green": if "A"<=text[0]<="Z":colored_text+=white_on_green+text[0]+normal else:colored_text+=text[0] if "A"<=text[1]<="Z":colored_text+=white_on_green+text[1]+normal else:colored_text+=text[1] if "A"<=text[2]<="Z":colored_text+=white_on_green+text[2]+normal else:colored_text+=text[2] if "A"<=text[3]<="Z":colored_text+=white_on_green+text[3]+normal else:colored_text+=text[3] if "A"<=text[4]<="Z":colored_text+=white_on_green+text[4]+normal else:colored_text+=text[4] return colored_text elif color == "yellow": if "A"<=text[0]<="Z":colored_text+=white_on_yellow+text[0]+normal else:colored_text+=text[0] if "A"<=text[1]<="Z":colored_text+=white_on_yellow+text[1]+normal else:colored_text+=text[1] if "A"<=text[2]<="Z":colored_text+=white_on_yellow+text[2]+normal else:colored_text+=text[2] if "A"<=text[3]<="Z":colored_text+=white_on_yellow+text[3]+normal else:colored_text+=text[3] if "A"<=text[4]<="Z":colored_text+=white_on_yellow+text[4]+normal else:colored_text+=text[4] return colored_text else: return text# 6432189921 sim = 80.08% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_puzzle_word = puzzle_word new_guess_word = guess_word if guess_word[0] == puzzle_word[0]: correct = puzzle_word[0] + correct[1:] new_puzzle_word = '-' + new_puzzle_word[1:] new_guess_word = '-' + guess_word[1:] if guess_word[1] == puzzle_word[1]: correct = correct[0] +puzzle_word[1] + correct[2:] new_puzzle_word = new_puzzle_word[0] + '-' + new_puzzle_word[2:] new_guess_word = new_guess_word[0] + '-' + guess_word[2:] if guess_word[2] == puzzle_word[2]: correct = correct[0:2]+puzzle_word[2] + correct[3:] new_puzzle_word = new_puzzle_word[0:2]+ '-' + new_puzzle_word[3:] new_guess_word = new_guess_word[0:2]+ '-' + guess_word[3:] if guess_word[3] == puzzle_word[3]: correct = correct[0:3]+puzzle_word[3] + correct[4] new_puzzle_word = new_puzzle_word[0:3]+ '-' + new_puzzle_word[4] new_guess_word = new_guess_word[0:3]+ '-' + guess_word[4] if guess_word[4] == puzzle_word[4]: correct = correct[0:4]+puzzle_word[4] new_puzzle_word = new_puzzle_word[0:4]+ '-' new_guess_word = new_guess_word[0:4]+ '-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] == '-': pass elif guess_word[0] == puzzle_word[0]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = '*' + puzzle_word[1:] elif guess_word[0] == puzzle_word[1]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[0]+'*' + puzzle_word[2:] elif guess_word[0] == puzzle_word[2]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[0:2]+'*' + puzzle_word[3:] elif guess_word[0] == puzzle_word[3]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[0:3]+'*' + puzzle_word[4] elif guess_word[0] == puzzle_word[4]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[0:4]+'*' if guess_word[1] == '-': pass elif guess_word[1] == puzzle_word[0]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = '*' + puzzle_word[1:] elif guess_word[1] == puzzle_word[1]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[0]+'*' + puzzle_word[2:] elif guess_word[1] == puzzle_word[2]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[0:2]+'*' + puzzle_word[3:] elif guess_word[1] == puzzle_word[3]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[0:3]+'*' + puzzle_word[4] elif guess_word[1] == puzzle_word[4]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[0:4]+'*' if guess_word[2] == '-': pass elif guess_word[2] == puzzle_word[0]: wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:] puzzle_word = '*' + puzzle_word[1:] elif guess_word[2] == puzzle_word[1]: wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[0]+'*' + puzzle_word[2:] elif guess_word[2] == puzzle_word[2]: wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[0:2]+'*' + puzzle_word[3:] elif guess_word[2] == puzzle_word[3]: wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[0:3]+'*' + puzzle_word[4] elif guess_word[2] == puzzle_word[4]: wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[0:4]+'*' if guess_word[3] == '-': pass elif guess_word[3] == puzzle_word[0]: wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4] puzzle_word = '*' + puzzle_word[1:] elif guess_word[3] == puzzle_word[1]: wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4] puzzle_word = puzzle_word[0]+'*' + puzzle_word[2:] elif guess_word[3] == puzzle_word[2]: wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4] puzzle_word = puzzle_word[0:2]+'*' + puzzle_word[3:] elif guess_word[3] == puzzle_word[3]: wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4] puzzle_word = puzzle_word[0:3]+'*' + puzzle_word[4] elif guess_word[3] == puzzle_word[4]: wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4] puzzle_word = puzzle_word[0:4]+'*' if guess_word[4] == '-': pass elif guess_word[4] == puzzle_word[0]: wrong_position = wrong_position[0:4] + guess_word[4] puzzle_word = '*' + puzzle_word[1:] elif guess_word[4] == puzzle_word[1]: wrong_position = wrong_position[0:4] + guess_word[4] puzzle_word = puzzle_word[0]+'*' + puzzle_word[2:] elif guess_word[4] == puzzle_word[2]: wrong_position = wrong_position[0:4] + guess_word[4] puzzle_word = puzzle_word[0:2]+'*' + puzzle_word[3:] elif guess_word[4] == puzzle_word[3]: wrong_position = wrong_position[0:4] + guess_word[4] puzzle_word = puzzle_word[0:3]+'*' + puzzle_word[4] elif guess_word[4] == puzzle_word[4]: wrong_position = wrong_position[0:4] + guess_word[4] puzzle_word = puzzle_word[0:4]+'*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): operate_replacestr = '' if k == 0: operate_replacestr = ch + original_str[1:] if k == 1: operate_replacestr = original_str[0]+ ch + original_str[2:] if k == 2: operate_replacestr = original_str[0:2]+ ch + original_str[3:] if k == 3: operate_replacestr = original_str[0:3]+ ch + original_str[4] if k == 4: operate_replacestr = original_str[0:4]+ ch return operate_replacestr def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green': if text[0] != '?' and text[0] != '*' : colored_text += white_on_green + text[0] + normal else: colored_text += text[0] if text[1] != '?' and text[1] != '*' : colored_text += white_on_green + text[1] + normal else: colored_text += text[1] if text[2] != '?' and text[2] != '*' : colored_text += white_on_green + text[2] + normal else: colored_text += text[2] if text[3] != '?' and text[3] != '*' : colored_text += white_on_green + text[3] + normal else: colored_text += text[3] if text[4] != '?' and text[4] != '*' : colored_text += white_on_green + text[4] + normal else: colored_text += text[4] return colored_text if color == 'yellow': if text[0] != '*' and text[0] != '?' and text[0] != '-' : colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if text[1] != '*' and text[1] != '?' and text[1] != '-' : colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if text[2] != '*' and text[2] != '?' and text[2] != '-' : colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if text[3] != '*' and text[3] != '?' and text[3] != '-' : colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if text[4] != '*' and text[4] != '?' and text[4] != '-' : colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text else: return text# 6430174021 sim = 78.51% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position += 1 elif ch == word[1]: position += 2 elif ch == word[2]: position += 3 elif ch == word[3]: position += 4 elif ch == word[4]: position += 5 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: correct += guess_word[0] new_puzzle_word = '-' + new_puzzle_word[1:] new_guess_word = '-' + new_guess_word[1:] else: correct += '?' if guess_word[1] == puzzle_word[1]: correct += guess_word[1] new_puzzle_word = new_puzzle_word[0] + '-' + new_puzzle_word[2:] new_guess_word = new_guess_word[0] + '-' + new_guess_word[2:] else: correct += '?' if guess_word[2] == puzzle_word[2]: correct += guess_word[2] new_puzzle_word = new_puzzle_word[:2] + '-' + new_puzzle_word[3:] new_guess_word = new_guess_word[:2] + '-' + new_guess_word[3:] else: correct += '?' if guess_word[3] == puzzle_word[3]: correct += guess_word[3] new_puzzle_word = new_puzzle_word[:3] + '-' + new_puzzle_word[4:] new_guess_word = new_guess_word[:3] + '-' + new_guess_word[4:] else: correct += '?' if guess_word[4] == puzzle_word[4]: correct += guess_word[4] new_puzzle_word = new_puzzle_word[:4] +'-' new_guess_word = new_guess_word[:4] + '-' else: correct += '?' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if (guess_word[0] in puzzle_word) and guess_word[0] != '-': wrong_position += guess_word[0] if guess_word[0] == puzzle_word[1]: puzzle_word = puzzle_word[:1] + ' ' + puzzle_word[2:] elif guess_word[0] == puzzle_word[2]: puzzle_word = puzzle_word[:2] + ' ' + puzzle_word[3:] elif guess_word[0] == puzzle_word[3]: puzzle_word = puzzle_word[:3] + ' ' + puzzle_word[4:] elif guess_word[0] == puzzle_word[4]: puzzle_word = puzzle_word[:4] + ' ' else: wrong_position += '*' if (guess_word[1] in puzzle_word) and guess_word[1] != '-': wrong_position += guess_word[1] if guess_word[1] == puzzle_word[0]: puzzle_word = ' ' + puzzle_word[1:] elif guess_word[1] == puzzle_word[2]: puzzle_word = puzzle_word[:2] + ' ' + puzzle_word[3:] elif guess_word[1] == puzzle_word[3]: puzzle_word = puzzle_word[:3] + ' ' + puzzle_word[4:] elif guess_word[1] == puzzle_word[4]: puzzle_word = puzzle_word[:4] + ' ' else: wrong_position += '*' if (guess_word[2] in puzzle_word) and guess_word[2] != '-': wrong_position += guess_word[2] if guess_word[2] == puzzle_word[0]: puzzle_word = ' ' + puzzle_word[1:] elif guess_word[2] == puzzle_word[1]: puzzle_word = puzzle_word[:1] + ' ' + puzzle_word[2:] elif guess_word[2] == puzzle_word[3]: puzzle_word = puzzle_word[:3] + ' ' + puzzle_word[4:] elif guess_word[2] == puzzle_word[4]: puzzle_word = puzzle_word[:4] + ' ' else: wrong_position += '*' if (guess_word[3] in puzzle_word) and guess_word[3] != '-': wrong_position += guess_word[3] if guess_word[3] == puzzle_word[0]: puzzle_word = ' ' + puzzle_word[1:] elif guess_word[3] == puzzle_word[1]: puzzle_word = puzzle_word[:1] + ' ' + puzzle_word[2:] elif guess_word[3] == puzzle_word[2]: puzzle_word = puzzle_word[:2] + ' ' + puzzle_word[3:] elif guess_word[3] == puzzle_word[4]: puzzle_word = puzzle_word[:4] + ' ' else: wrong_position += '*' if (guess_word[4] in puzzle_word) and guess_word[4] != '-': wrong_position += guess_word[4] if guess_word[4] == puzzle_word[0]: puzzle_word = ' ' + puzzle_word[1:] elif guess_word[4] == puzzle_word[1]: puzzle_word = puzzle_word[:1] + ' ' + puzzle_word[2:] elif guess_word[4] == puzzle_word[2]: puzzle_word = puzzle_word[:2] + ' ' + puzzle_word[3:] elif guess_word[4] == puzzle_word[3]: puzzle_word = puzzle_word[:3] + ' ' + puzzle_word[4:] else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): replace_str = original_str[:k] + ch + original_str[k+1:] return replace_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text[0] != '?' and text[0] != '*' and text[0] != '-': if color == 'green': colored_text += white_on_green + text[0] + normal elif color == 'yellow': colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if text[1] != '?' and text[1] != '*' and text[1] != '-': if color == 'green': colored_text += white_on_green + text[1] + normal elif color == 'yellow': colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if text[2] != '?' and text[2] != '*' and text[2] != '-': if color == 'green': colored_text += white_on_green + text[2] + normal elif color == 'yellow': colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if text[3] != '?' and text[3] != '*' and text[3] != '-': if color == 'green': colored_text += white_on_green + text[3] + normal elif color == 'yellow': colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if text[4] != '?' and text[4] != '*' and text[4] != '-': if color == 'green': colored_text += white_on_green + text[4] + normal elif color == 'yellow': colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text# 6430234021 sim = 78.51% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch : position = 0 elif word[1] == ch : position = 1 elif word[2] == ch : position = 2 elif word[3] == ch : position = 3 elif word[4] == ch : position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0] : correct += guess_word[0] new_puzzle_word = '-'+new_puzzle_word[1:5] new_guess_word = '-'+new_guess_word[1:5] else: correct += '?' if guess_word[1] == puzzle_word[1] : correct += guess_word[1] new_puzzle_word = new_puzzle_word[0]+'-'+new_puzzle_word[2:5] new_guess_word = new_guess_word[0]+'-'+new_guess_word[2:5] else: correct += '?' if guess_word[2] == puzzle_word[2] : correct += guess_word[2] new_puzzle_word = new_puzzle_word[0:2]+'-'+new_puzzle_word[3:5] new_guess_word = new_guess_word[0:2]+'-'+new_guess_word[3:5] else: correct += '?' if guess_word[3] == puzzle_word[3] : correct += guess_word[3] new_puzzle_word = new_puzzle_word[0:3]+'-'+new_puzzle_word[4] new_guess_word = new_guess_word[0:3]+'-'+new_guess_word[4] else: correct += '?' if guess_word[4] == puzzle_word[4] : correct += guess_word[4] new_puzzle_word = new_puzzle_word[0:4]+'-' new_guess_word = new_guess_word[0:4]+'-' else: correct += '?' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0] : wrong_position += guess_word[0] if guess_word[0] == puzzle_word[1] : puzzle_word = puzzle_word[0]+'!'+puzzle_word[2:5] elif guess_word[0] == puzzle_word[2] : puzzle_word = puzzle_word[0:2]+'!'+puzzle_word[3:5] elif guess_word[0] == puzzle_word[3] : puzzle_word = puzzle_word[0:3]+'!'+puzzle_word[4] elif guess_word[0] == puzzle_word[4] : puzzle_word = puzzle_word[0:4]+'!' else: wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1] : wrong_position += guess_word[1] if guess_word[1] == puzzle_word[0] : puzzle_word = '!'+puzzle_word[1:5] elif guess_word[1] == puzzle_word[2] : puzzle_word = puzzle_word[0:2]+'!'+puzzle_word[3:5] elif guess_word[1] == puzzle_word[3] : puzzle_word = puzzle_word[0:3]+'!'+puzzle_word[4] elif guess_word[1] == puzzle_word[4] : puzzle_word = puzzle_word[0:4]+'!' else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2] : wrong_position += guess_word[2] if guess_word[2] == puzzle_word[0] : puzzle_word = '!'+puzzle_word[1:5] elif guess_word[2] == puzzle_word[1] : puzzle_word = puzzle_word[0]+'!'+puzzle_word[2:5] elif guess_word[2] == puzzle_word[3] : puzzle_word = puzzle_word[0:3]+'!'+puzzle_word[4] elif guess_word[2] == puzzle_word[4] : puzzle_word = puzzle_word[0:4]+'!' else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3] : wrong_position += guess_word[3] if guess_word[3] == puzzle_word[0] : puzzle_word = '!'+puzzle_word[1:5] elif guess_word[3] == puzzle_word[1] : puzzle_word = puzzle_word[0]+'!'+puzzle_word[2:5] elif guess_word[3] == puzzle_word[2] : puzzle_word = puzzle_word[0:2]+'!'+puzzle_word[3:5] elif guess_word[3] == puzzle_word[4] : puzzle_word = puzzle_word[0:4]+'!' else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4] : wrong_position += guess_word[4] if guess_word[4] == puzzle_word[0] : puzzle_word = '!'+puzzle_word[1:5] elif guess_word[4] == puzzle_word[1] : puzzle_word = puzzle_word[0]+'!'+puzzle_word[2:5] elif guess_word[4] == puzzle_word[2] : puzzle_word = puzzle_word[0:2]+'!'+puzzle_word[3:5] elif guess_word[4] == puzzle_word[3] : puzzle_word = puzzle_word[0:3]+'!'+puzzle_word[4] else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): replace = original_str[0:int(k)]+ch+original_str[int(k)+1:5] return replace def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green' : if text[0] != '?' : colored_text += white_on_green + text[0] + normal elif text[0] == '?' : colored_text += '?' if text[1] != '?' : colored_text += white_on_green + text[1] + normal elif text[1] == '?' : colored_text += '?' if text[2] != '?' : colored_text += white_on_green + text[2] + normal elif text[2] == '?' : colored_text += '?' if text[3] != '?' : colored_text += white_on_green + text[3] + normal elif text[3] == '?' : colored_text += '?' if text[4] != '?' : colored_text += white_on_green + text[4] + normal elif text[4] == '?' : colored_text += '?' if color == 'yellow' : if text[0] != '*' : colored_text += white_on_yellow + text[0] + normal elif text[0] == '*' : colored_text += '*' if text[1] != '*' : colored_text += white_on_yellow + text[1] + normal elif text[1] == '*' : colored_text += '*' if text[2] != '*' : colored_text += white_on_yellow + text[2] + normal elif text[2] == '*' : colored_text += '*' if text[3] != '*' : colored_text += white_on_yellow + text[3] + normal elif text[3] == '*' : colored_text += '*' if text[4] != '*' : colored_text += white_on_yellow + text[4] + normal elif text[4] == '*' : colored_text += '*' return colored_text# 6430228321 sim = 78.15% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 else: pass return position def check_correct_position(puzzle_word, guess_word): new_guess_word = '' correct = '' if guess_word[0] == puzzle_word[0]: correct += guess_word[0] puzzle_word = "-" + puzzle_word[1:] new_guess_word = "-" + guess_word[1:] else: correct += "?" if guess_word[1] == puzzle_word[1]: correct += guess_word[1] puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] new_guess_word = guess_word[0] + "-" + guess_word[2:] else: correct += "?" if guess_word[2] == puzzle_word[2]: correct += guess_word[2] puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] new_guess_word = guess_word[:2] + "-" + guess_word[3:] else: correct += "?" if guess_word[3] == puzzle_word[3]: correct += guess_word[3] puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4] new_guess_word = guess_word[:3] + "-" + guess_word[4] else: correct += "?" if guess_word[4] == puzzle_word[4]: correct += guess_word[4] puzzle_word = puzzle_word[:4] + "-" new_guess_word = guess_word[:4] + "-" else: correct += "?" new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0]: wrong_position += guess_word[0] if guess_word[0] == puzzle_word[1]: puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] elif guess_word[0] == puzzle_word[2]: puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[0] == puzzle_word[3]: puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4] elif guess_word[0] == puzzle_word[4]: puzzle_word = puzzle_word[:4] + "-" else: wrong_position += "*" if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: wrong_position += guess_word[1] if guess_word[1] == puzzle_word[0]: puzzle_word = "-" + puzzle_word[1:] elif guess_word[1] == puzzle_word[2]: puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[1] == puzzle_word[3]: puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4] elif guess_word[1] == puzzle_word[4]: puzzle_word = puzzle_word[:4] + "-" else: wrong_position += "*" if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: wrong_position += guess_word[2] if guess_word[2] == puzzle_word[0]: puzzle_word = "-" + puzzle_word[1:] elif guess_word[2] == puzzle_word[1]: puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] elif guess_word[2] == puzzle_word[3]: puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4] elif guess_word[2] == puzzle_word[4]: puzzle_word = puzzle_word[:4] + "-" else: wrong_position += "*" if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: wrong_position += guess_word[3] if guess_word[3] == puzzle_word[0]: puzzle_word = "-" + puzzle_word[1:] elif guess_word[3] == puzzle_word[1]: puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] elif guess_word[3] == puzzle_word[2]: puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[3] == puzzle_word[4]: puzzle_word = puzzle_word[:4] + "-" else: wrong_position += "*" if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: wrong_position += guess_word[4] if guess_word[4] == puzzle_word[0]: puzzle_word = "-" + puzzle_word[1:] elif guess_word[4] == puzzle_word[1]: puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] elif guess_word[4] == puzzle_word[2]: puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[4] == puzzle_word[3]: puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4] else: wrong_position += "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0: original_str = str(ch) + original_str[1:] elif k == 1: original_str = original_str[0] + str(ch) + original_str[2:] elif k == 2: original_str = original_str[:2] + str(ch) + original_str[3:] elif k == 3: original_str = original_str[:3] + str(ch) + original_str[4] else: original_str = original_str[:4] + str(ch) return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == "green": if "A" <= text[0] <= "Z": colored_text += white_on_green + text[0] + normal else: colored_text += text[0] if "A" <= text[1] <= "Z": colored_text += white_on_green + text[1] + normal else: colored_text += text[1] if "A" <= text[2] <= "Z": colored_text += white_on_green + text[2] + normal else: colored_text += text[2] if "A" <= text[3] <= "Z": colored_text += white_on_green + text[3] + normal else: colored_text += text[3] if "A" <= text[4] <= "Z": colored_text += white_on_green + text[4] + normal else: colored_text += text[4] elif color == "yellow": if "A" <= text[0] <= "Z": colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if "A" <= text[1] <= "Z": colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if "A" <= text[2] <= "Z": colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if "A" <= text[3] <= "Z": colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if "A" <= text[4] <= "Z": colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text# 6430285021 sim = 77.19% import random import string def position_in_word(ch, word): if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word new_guess_word = "" new_puzzle_word = "" if guess_word[0] in puzzle_word[0]: new_guess_word += "-" correct += guess_word[0] new_puzzle_word += "-" else: new_guess_word += guess_word[0] correct += "?" new_puzzle_word += puzzle_word[0] if guess_word[1] in puzzle_word[1]: new_guess_word += "-" correct += guess_word[1] new_puzzle_word += "-" else: new_guess_word += guess_word[1] correct += "?" new_puzzle_word += puzzle_word[1] if guess_word[2] in puzzle_word[2]: new_guess_word += "-" correct += guess_word[2] new_puzzle_word += "-" else: new_guess_word += guess_word[2] correct += "?" new_puzzle_word += puzzle_word[2] if guess_word[3] in puzzle_word[3]: new_guess_word += "-" correct += guess_word[3] new_puzzle_word += "-" else: new_guess_word += guess_word[3] correct += "?" new_puzzle_word += puzzle_word[3] if guess_word[4] in puzzle_word[4]: new_guess_word += "-" correct += guess_word[4] new_puzzle_word += "-" else: new_guess_word += guess_word[4] correct += "?" new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if "A" <=guess_word [0] <= "Z": if guess_word[0] == puzzle_word[0]: wrong_position += guess_word[0] puzzle_word = "_"+ puzzle_word[1:] elif guess_word[0] == puzzle_word[1]: wrong_position += guess_word[0] puzzle_word = puzzle_word[0]+"_"+ puzzle_word[2:] elif guess_word[0] == puzzle_word[2]: wrong_position += guess_word[0] puzzle_word = puzzle_word[0:2]+"_"+ puzzle_word[3:] elif guess_word[0] == puzzle_word[3]: wrong_position += guess_word[0] puzzle_word = puzzle_word[0:3]+"_"+ puzzle_word[4] elif guess_word[0] == puzzle_word[4]: wrong_position += guess_word[0] puzzle_word = puzzle_word[0:4]+"_" else: wrong_position += "*" else: wrong_position += "*" if "A" <=guess_word [1] <= "Z": if guess_word[1] == puzzle_word[0]: wrong_position += guess_word[1] puzzle_word = "_"+ puzzle_word[1:] elif guess_word[1] == puzzle_word[1]: wrong_position += guess_word[1] puzzle_word = puzzle_word[0]+"_"+ puzzle_word[2:] elif guess_word[1] == puzzle_word[2]: wrong_position += guess_word[1] puzzle_word = puzzle_word[0:2]+"_"+ puzzle_word[3:] elif guess_word[1] == puzzle_word[3]: wrong_position += guess_word[1] puzzle_word = puzzle_word[0:3]+"_"+ puzzle_word[4] elif guess_word[1] == puzzle_word[4]: wrong_position += guess_word[1] puzzle_word = puzzle_word[0:4]+"_" else: wrong_position += "*" else: wrong_position += "*" if "A" <=guess_word [2] <= "Z": if guess_word[2] == puzzle_word[0]: wrong_position += guess_word[2] puzzle_word = "_"+ puzzle_word[1:] elif guess_word[2] == puzzle_word[1]: wrong_position += guess_word[2] puzzle_word = puzzle_word[0]+"_"+ puzzle_word[2:] elif guess_word[2] == puzzle_word[2]: wrong_position += guess_word[0] puzzle_word = puzzle_word[0:2]+"_"+ puzzle_word[3:] elif guess_word[2] == puzzle_word[3]: wrong_position += guess_word[2] puzzle_word = puzzle_word[0:3]+"_"+ puzzle_word[4] elif guess_word[2] == puzzle_word[4]: wrong_position += guess_word[2] puzzle_word = puzzle_word[0:4]+"_" else: wrong_position += "*" else: wrong_position += "*" if "A" <=guess_word [3] <= "Z": if guess_word[3] == puzzle_word[0]: wrong_position += guess_word[3] puzzle_word = "_"+ puzzle_word[1:] elif guess_word[3] == puzzle_word[1]: wrong_position += guess_word[3] puzzle_word = puzzle_word[0]+"_"+ puzzle_word[2:] elif guess_word[3] == puzzle_word[2]: wrong_position += guess_word[3] puzzle_word = puzzle_word[0:2]+"_"+ puzzle_word[3:] elif guess_word[3] == puzzle_word[3]: wrong_position += guess_word[3] puzzle_word = puzzle_word[0:3]+"_"+ puzzle_word[4] elif guess_word[3] == puzzle_word[4]: wrong_position += guess_word[3] puzzle_word = puzzle_word[0:4]+"_" else: wrong_position += "*" else: wrong_position += "*" if "A" <=guess_word [4] <= "Z": if guess_word[4] == puzzle_word[0]: wrong_position += guess_word[4] puzzle_word = "_"+ puzzle_word[1:] elif guess_word[4] == puzzle_word[1]: wrong_position += guess_word[4] puzzle_word = puzzle_word[0]+"_"+ puzzle_word[2:] elif guess_word[4] == puzzle_word[2]: wrong_position += guess_word[4] puzzle_word = puzzle_word[0:2]+"_"+ puzzle_word[3:] elif guess_word[4] == puzzle_word[3]: wrong_position += guess_word[4] puzzle_word = puzzle_word[0:3]+"_"+ puzzle_word[4] elif guess_word[4] == puzzle_word[4]: wrong_position += guess_word[4] puzzle_word = puzzle_word[0:4]+"_" else: wrong_position += "*" else: wrong_position += "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): replace_kth_letter_in_str = "" if k == "0": replace_kth_letter_in_str += ch +original_str[1:5:1] elif k == "1": replace_kth_letter_in_str += original_str[:1] + ch + original_str[2:5] elif k == "2": replace_kth_letter_in_str += original_str[:2] + ch + original_str[3:5] elif k == "3": replace_kth_letter_in_str += original_str[:3] + ch + original_str[4:5] elif k == "4": replace_kth_letter_in_str += original_str[:4] + ch return replace_kth_letter_in_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == "green": if "A" <= text[0] <= "Z" : colored_text += white_on_green + text[0] + normal else: colored_text += text[0] if "A" <= text[1] <= "Z" : colored_text += white_on_green + text[1] + normal else: colored_text += text[1] if "A" <= text[2] <= "Z" : colored_text += white_on_green + text[2] + normal else: colored_text += text[2] if "A" <= text[3] <= "Z" : colored_text += white_on_green + text[3] + normal else: colored_text += text[3] if "A" <= text[4] <= "Z" : colored_text += white_on_green + text[4] + normal else: colored_text += text[4] if color == "yellow": if "A" <= text[0] <= "Z" : colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if "A" <= text[1] <= "Z" : colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if "A" <= text[2] <= "Z" : colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if "A" <= text[3] <= "Z" : colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if "A" <= text[4] <= "Z" : colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text# 6430373621 sim = 76.94% import random import string def position_in_word(ch, word): if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0] : correct = guess_word[0] + correct[1:] new_puzzle_word = "-" + new_puzzle_word[1:] new_guess_word = "-" + new_guess_word[1:] if puzzle_word[1] == guess_word[1] : correct = correct[0] + guess_word[1] + correct[2:] new_puzzle_word = new_puzzle_word[0] + "-" + new_puzzle_word[2:] new_guess_word = new_guess_word[0] + "-" + new_guess_word[2:] if puzzle_word[2] == guess_word[2] : correct = correct[:2] + guess_word[2] + correct[3:] new_puzzle_word = new_puzzle_word[:2] + "-" + new_puzzle_word[3:] new_guess_word = new_guess_word[:2] + "-" + new_guess_word[3:] if puzzle_word[3] == guess_word[3] : correct = correct[:3] + guess_word[3] + correct[4:] new_puzzle_word = new_puzzle_word[:3] + "-" + new_puzzle_word[4:] new_guess_word = new_guess_word[:3] + "-" + new_guess_word[4:] if puzzle_word[4] == guess_word[4] : correct = correct[:4] + guess_word[4] new_puzzle_word = new_puzzle_word[:4] + "-" new_guess_word = new_guess_word[:4] + "-" return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if 'A'<= guess_word[0] <= 'Z' : if guess_word[0] in puzzle_word[0] : wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = "!" + puzzle_word[1:] elif guess_word[0] in puzzle_word[1] : wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[0] + "!" + puzzle_word[2:] elif guess_word[0] in puzzle_word[2] : wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[:2] + "!" + puzzle_word[3:] elif guess_word[0] in puzzle_word[3] : wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[:3] + "!" + puzzle_word[4] elif guess_word[0] in puzzle_word[4] : wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[:4] + "!" if 'A'<= guess_word[1] <= 'Z' : if guess_word[1] in puzzle_word[0] : wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = "!" + puzzle_word[1:] elif guess_word[1] in puzzle_word[1] : wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[0] + "!" + puzzle_word[2:] elif guess_word[1] in puzzle_word[2] : wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[:2] + "!" + puzzle_word[3:] elif guess_word[1] in puzzle_word[3] : wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[:3] + "!" + puzzle_word[4] elif guess_word[1] in puzzle_word[4] : wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[:4] + "!" if 'A'<= guess_word[2] <= 'Z' : if guess_word[2] in puzzle_word[0] : wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] puzzle_word = "!" + puzzle_word[1:] elif guess_word[2] in puzzle_word[1] : wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[0] + "!" + puzzle_word[2:] elif guess_word[2] in puzzle_word[2] : wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[:2] + "!" + puzzle_word[3:] elif guess_word[2] in puzzle_word[3] : wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[:3] + "!" + puzzle_word[4] elif guess_word[2] in puzzle_word[4] : wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[:4] + "!" if 'A'<= guess_word[3] <= 'Z' : if guess_word[3] in puzzle_word[0] : wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4:] puzzle_word = "!" + puzzle_word[1:] elif guess_word[3] in puzzle_word[1] : wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4:] puzzle_word = puzzle_word[0] + "!" + puzzle_word[2:] elif guess_word[3] in puzzle_word[2] : wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4:] puzzle_word = puzzle_word[:2] + "!" + puzzle_word[3:] elif guess_word[3] in puzzle_word[3] : wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4:] puzzle_word = puzzle_word[:3] + "!" + puzzle_word[4] elif guess_word[3] in puzzle_word[4] : wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4:] puzzle_word = puzzle_word[:4] + "!" if 'A'<= guess_word[4] <= 'Z' : if guess_word[4] in puzzle_word[0] : wrong_position = wrong_position[:4] + guess_word[4] puzzle_word = "!" + puzzle_word[1:] elif guess_word[4] in puzzle_word[1] : wrong_position = wrong_position[:4] + guess_word[4] puzzle_word = puzzle_word[0] + "!" + puzzle_word[2:] elif guess_word[4] in puzzle_word[2] : wrong_position = wrong_position[:4] + guess_word[4] puzzle_word = puzzle_word[:2] + "!" + puzzle_word[3:] elif guess_word[4] in puzzle_word[3] : wrong_position = wrong_position[:4] + guess_word[4] puzzle_word = puzzle_word[:3] + "!" + puzzle_word[4] elif guess_word[4] in puzzle_word[4] : wrong_position = wrong_position[:4] + guess_word[4] puzzle_word = puzzle_word[:4] + "!" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): new_str='' if k == "0" : new_str = ch + original_str[1:] elif k == "1" : new_str = original_str[0] + ch + original_str[2:] elif k == "2" : new_str = original_str[:2] + ch + original_str[3:] elif k == "3" : new_str = original_str[:3] + ch + original_str[4:] elif k == "4" : new_str = original_str[:4] + ch return new_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' ch1,ch2,ch3,ch4,ch5 = text[0],text[1],text[2],text[3],text[4] if color == "green" and "A" <= text[0] <= "Z" : ch1 = white_on_green + text[0] + normal if color == "green" and "A" <= text[1] <= "Z" : ch2 = white_on_green + text[1] + normal if color == "green" and "A" <= text[2] <= "Z" : ch3 = white_on_green + text[2] + normal if color == "green" and "A" <= text[3] <= "Z" : ch4 = white_on_green + text[3] + normal if color == "green" and "A" <= text[4] <= "Z" : ch5 = white_on_green + text[4] + normal if color == "yellow" and "A" <= text[0] <= "Z" : ch1 = white_on_yellow + text[0] + normal if color == "yellow" and "A" <= text[1] <= "Z" : ch2 = white_on_yellow + text[1] + normal if color == "yellow" and "A" <= text[2] <= "Z" : ch3 = white_on_yellow + text[2] + normal if color == "yellow" and "A" <= text[3] <= "Z" : ch4 = white_on_yellow + text[3] + normal if color == "yellow" and "A" <= text[4] <= "Z" : ch5 = white_on_yellow + text[4] + normal colored_text = ch1 + ch2 +ch3 + ch4 + ch5 return colored_text# 6432134321 sim = 76.94% import random import string def position_in_word(ch, word): if ch in word: if ch[0] == word[0]: position = 0 if ch[1] == word[1]: position = 1 if ch[2] == word[2]: position = 2 if ch[3] == word[3]: position = 3 if ch[4] == word[4]: position = 4 position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = "?????" if puzzle_word[0] == guess_word[0]: correct = guess_word[0]+correct[1:] puzzle_word = "-" + puzzle_word[1:] guess_word = "-" + guess_word[1:] if puzzle_word[1] == guess_word[1]: correct = correct[0] + guess_word[1] + correct[2:] puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] guess_word = guess_word[0] + "-" + guess_word[2:] if puzzle_word[2] == guess_word[2]: correct = correct[:2] + guess_word[2] + correct[3:] puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] guess_word = guess_word[:2] + "-" + guess_word[3:] if puzzle_word[3] == guess_word[3]: correct = correct[:3] + guess_word[3] + correct[4] puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4] guess_word = guess_word[:3] + "-" + guess_word[4] if puzzle_word[4] == guess_word[4]: correct = correct[:4] + guess_word[4] puzzle_word = puzzle_word[:4] + "-" guess_word = guess_word[:4] + "-" new_guess_word = guess_word correct new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = "*****" if (guess_word[0] in puzzle_word) and (guess_word[0] != "-"): if guess_word[0] == puzzle_word[0]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = "-" + puzzle_word[1:] elif guess_word[0] == puzzle_word[1]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] elif guess_word[0] == puzzle_word[2]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[0] == puzzle_word[3]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4] elif guess_word[0] == puzzle_word[4]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[:4] + "-" if (guess_word[1] in puzzle_word) and (guess_word[1] != "-"): if guess_word[1] == puzzle_word[0]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = "-" + puzzle_word[1:] elif guess_word[1] == puzzle_word[1]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] elif guess_word[1] == puzzle_word[2]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[1] == puzzle_word[3]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4] elif guess_word[1] == puzzle_word[4]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[:4] + "-" if (guess_word[2] in puzzle_word) and (guess_word[2] != "-"): if guess_word[2] == puzzle_word[0]: wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] puzzle_word = "-" + puzzle_word[1:] elif guess_word[2] == puzzle_word[1]: wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] elif guess_word[2] == puzzle_word[2]: wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[2] == puzzle_word[3]: wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4] elif guess_word[2] == puzzle_word[4]: wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[:4] + "-" if (guess_word[3] in puzzle_word) and (guess_word[3] != "-"): if guess_word[3] == puzzle_word[0]: wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4] puzzle_word = "-" + puzzle_word[1:] elif guess_word[3] == puzzle_word[1]: wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4] puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] elif guess_word[3] == puzzle_word[2]: wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4] puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[3] == puzzle_word[3]: wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4] puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4] elif guess_word[3] == puzzle_word[4]: wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4] puzzle_word = puzzle_word[:4] + "-" if (guess_word[4] in puzzle_word) and (guess_word[4] != "-"): if guess_word[4] == puzzle_word[0]: wrong_position = wrong_position[:4] + guess_word[4] puzzle_word = "-" + puzzle_word[1:] elif guess_word[4] == puzzle_word[1]: wrong_position = wrong_position[:4] + guess_word[4] puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] elif guess_word[4] == puzzle_word[2]: wrong_position = wrong_position[:4] + guess_word[4] puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[4] == puzzle_word[3]: wrong_position = wrong_position[:4] + guess_word[4] puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4] elif guess_word[4] == puzzle_word[4]: wrong_position = wrong_position[:4] + guess_word[4] puzzle_word = puzzle_word[:4] + "-" wrong_position return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0: original_str = ch + original_str[1:] if k == 1: original_str = original_str[0] + ch + original_str[2:] if k == 2: original_str = original_str[:2] + ch + original_str[3:] if k == 3: original_str = original_str[:3] + ch + original_str[4] if k == 4: original_str = original_str[:4] + ch new_replace = original_str return new_replace def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if text[0] != "?" and text[0] != "*": if color == "green": ch1 = white_on_green + text[0] + normal if color == "yellow": ch1 = white_on_yellow + text[0] + normal else: ch1 = text[0] if text[1] != "?" and text[1] != "*": if color == "green": ch2 = white_on_green + text[1] + normal if color == "yellow": ch2 = white_on_yellow + text[1] + normal else: ch2 = text[1] if text[2] != "?" and text[2] != "*": if color == "green": ch3 = white_on_green + text[2] + normal if color == "yellow": ch3 = white_on_yellow + text[2] + normal else: ch3 = text[2] if text[3] != "?" and text[3] != "*": if color == "green": ch4 = white_on_green + text[3] + normal if color == "yellow": ch4 = white_on_yellow + text[3] + normal else: ch4 = text[3] if text[4] != "?" and text[4] != "*": if color == "green": ch5 = white_on_green + text[4] + normal if color == "yellow": ch5 = white_on_yellow + text[4] + normal else: ch5 = text[4] text = ch1+ch2+ch3+ch4+ch5 colored_text = text return colored_text# 6430257521 sim = 76.68% import random import string def position_in_word(ch, word): if ch in word[0] : position = 0 elif ch in word[1] : position = 1 elif ch in word[2] : position = 2 elif ch in word[3] : position = 3 elif ch in word[4] : position = 4 elif not (ch in word) : position = -1 position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = "?????" new_puzzle_word = puzzle_word new_guess_word = guess_word if guess_word[0] == puzzle_word[0] : correct = guess_word[0] + correct[1:] new_puzzle_word = "-" + new_puzzle_word[1:] new_guess_word = "-" + new_guess_word[1:] if guess_word[1] == puzzle_word[1] : correct = correct[0] + guess_word[1] + correct[2:] new_puzzle_word = new_puzzle_word[0] + "-" + new_puzzle_word[2:] new_guess_word = new_guess_word[0] + "-" + new_guess_word[2:] if guess_word[2] == puzzle_word[2] : correct = correct[:2] + guess_word[2] + correct[3:] new_puzzle_word = new_puzzle_word[:2] + "-" + new_puzzle_word[3:] new_guess_word = new_guess_word[:2] + "-" + new_guess_word[3:] if guess_word[3] == puzzle_word[3] : correct = correct[:3] + guess_word[3] + correct[4:] new_puzzle_word = new_puzzle_word[:3] + "-" + new_puzzle_word[4:] new_guess_word = new_guess_word[:3] + "-" + new_guess_word[4:] if guess_word[4] == puzzle_word[4] : correct = correct[:4] + guess_word[4] new_puzzle_word = new_puzzle_word[:4] + "-" new_guess_word = new_guess_word[:4] + "-" return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): x = "" if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0] : x += guess_word[0] if guess_word[0] == puzzle_word[1] : puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] elif guess_word[0] == puzzle_word[2] : puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[0] == puzzle_word[3] : puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4:] elif guess_word[0] == puzzle_word[4] : puzzle_word = puzzle_word[:4] + "-" else : x += "*" if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1] : x += guess_word[1] if guess_word[1] == puzzle_word[0] : puzzle_word = "-" + puzzle_word[1:] elif guess_word[1] == puzzle_word[2] : puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[1] == puzzle_word[3] : puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4:] elif guess_word[1] == puzzle_word[4] : puzzle_word = puzzle_word[:4] + "-" else : x += "*" if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2] : x += guess_word[2] if guess_word[2] == puzzle_word[0] : puzzle_word = "-" + puzzle_word[1:] elif guess_word[2] == puzzle_word[1] : puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] elif guess_word[2] == puzzle_word[3] : puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4:] elif guess_word[2] == puzzle_word[4] : puzzle_word = puzzle_word[:4] + "-" else : x +="*" if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3] : x += guess_word[3] if guess_word[3] == puzzle_word[0] : puzzle_word = "-" + puzzle_word[1:] elif guess_word[3] == puzzle_word[1] : puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] elif guess_word[3] == puzzle_word[2] : puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[3] == puzzle_word[4] : puzzle_word = puzzle_word[:4] + "-" else : x +="*" if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4] : x += guess_word[4] if guess_word[4] == puzzle_word[0] : puzzle_word = "-" + puzzle_word[1:] elif guess_word[4] == puzzle_word[1] : puzzle_word = puzzle_word[0] + "-" + puzzle_word[2:] elif guess_word[4] == puzzle_word[2] : puzzle_word = puzzle_word[:2] + "-" + puzzle_word[3:] elif guess_word[4] == puzzle_word[3] : puzzle_word = puzzle_word[:3] + "-" + puzzle_word[4:] else : x +="*" wrong_position = x return wrong_position def replace_kth_letter_in_str(original_str, k, ch): replace = original_str[0:k] + ch + original_str[k+1:] return replace def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" if text[0] in A : if color == "green" : x0 = white_on_green + text[0] + normal if color == "yellow" : x0 = white_on_yellow + text[0] + normal else : x0 = text[0] if text[1] in A : if color == "green" : x1 = white_on_green + text[1] + normal if color == "yellow" : x1 = white_on_yellow + text[1] + normal else : x1 = text[1] if text[2] in A : if color == "green" : x2 = white_on_green + text[2] + normal if color == "yellow" : x2 = white_on_yellow + text[2] + normal else : x2 = text[2] if text[3] in A : if color == "green" : x3 = white_on_green + text[3] + normal if color == "yellow" : x3 = white_on_yellow + text[3] + normal else : x3 = text[3] if text[4] in A : if color == "green" : x4 = white_on_green + text[4] + normal if color == "yellow" : x4 = white_on_yellow + text[4] + normal else : x4 = text[4] colored_text = x0+x1+x2+x3+x4 return colored_text# 6432016021 sim = 76.68% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0] : new_guess_word = "-" + guess_word[1:5] correct += guess_word[0] new_puzzle_word = "-" + puzzle_word[1:5] else : correct += "?" if guess_word[1] == puzzle_word[1] : new_guess_word = new_guess_word[0] + "-" + guess_word[2:5] correct += guess_word[1] new_puzzle_word = new_puzzle_word[0] + "-" + puzzle_word[2:5] else : correct += "?" if guess_word[2] == puzzle_word[2] : new_guess_word = new_guess_word[0:2] + "-" + guess_word[3:5] correct += guess_word[2] new_puzzle_word = new_puzzle_word[0:2] + "-" + puzzle_word[3:5] else : correct += "?" if guess_word[3] == puzzle_word[3] : new_guess_word = new_guess_word[0:3] + "-" + guess_word[4] correct += guess_word[3] new_puzzle_word = new_puzzle_word[0:3] + "-" + puzzle_word[4] else : correct += "?" if guess_word[4] == puzzle_word[4] : new_guess_word = new_guess_word[0:4] + "-" correct += guess_word[4] new_puzzle_word = new_puzzle_word[0:4] + "-" else : correct += "?" return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] == "-" : wrong_position += "*" elif guess_word[0] == puzzle_word[1] : wrong_position += guess_word[0] puzzle_word = puzzle_word[0] + '&' + puzzle_word[2:5] elif guess_word[0] == puzzle_word[2] : wrong_position += guess_word[0] puzzle_word = puzzle_word[0:2] + '&' + puzzle_word[3:5] elif guess_word[0] == puzzle_word[3] : wrong_position += guess_word[0] puzzle_word = puzzle_word[0:3] + '&' + puzzle_word[4] elif guess_word[0] == puzzle_word[4] : wrong_position += guess_word[0] puzzle_word = puzzle_word[0:4] + '&' else : wrong_position += "*" if guess_word[1] == "-" : wrong_position += "*" elif guess_word[1] == puzzle_word[0] : wrong_position += guess_word[1] puzzle_word = '&' + puzzle_word[1:5] elif guess_word[1] == puzzle_word[2] : wrong_position += guess_word[1] puzzle_word = puzzle_word[0:2] + '&' + puzzle_word[3:5] elif guess_word[1] == puzzle_word[3] : wrong_position += guess_word[1] puzzle_word = puzzle_word[0:3] + '&' + puzzle_word[4] elif guess_word[1] == puzzle_word[4] : wrong_position += guess_word[1] puzzle_word = puzzle_word[0:4] + '&' else : wrong_position += "*" if guess_word[2] == "-" : wrong_position += "*" elif guess_word[2] == puzzle_word[0] : wrong_position += guess_word[2] puzzle_word = '&' + puzzle_word[1:5] elif guess_word[2] == puzzle_word[1] : wrong_position += guess_word[2] puzzle_word = puzzle_word[0] + '&' + puzzle_word[2:5] elif guess_word[2] == puzzle_word[3] : wrong_position += guess_word[2] puzzle_word = puzzle_word[0:3] + '&' + puzzle_word[4] elif guess_word[2] == puzzle_word[4] : wrong_position += guess_word[2] puzzle_word = puzzle_word[0:4] + '&' else : wrong_position += "*" if guess_word[3] == "-" : wrong_position += "*" elif guess_word[3] == puzzle_word[0] : wrong_position += guess_word[3] puzzle_word = '&' + puzzle_word[1:5] elif guess_word[3] == puzzle_word[1] : wrong_position += guess_word[3] puzzle_word = puzzle_word[0] + '&' + puzzle_word[2:5] elif guess_word[3] == puzzle_word[2] : wrong_position += guess_word[3] puzzle_word = puzzle_word[0:2] + '&' + puzzle_word[3:5] elif guess_word[3] == puzzle_word[4] : wrong_position += guess_word[3] puzzle_word = puzzle_word[0:4] + '&' else : wrong_position += "*" if guess_word[4] == "-" : wrong_position += "*" elif guess_word[4] == puzzle_word[0] : wrong_position += guess_word[4] puzzle_word = '&' + puzzle_word[1:5] elif guess_word[4] == puzzle_word[1] : wrong_position += guess_word[4] puzzle_word = puzzle_word[0] + '&' + puzzle_word[2:5] elif guess_word[4] == puzzle_word[2] : wrong_position += guess_word[4] puzzle_word = puzzle_word[0:2] + '&' + puzzle_word[3:5] elif guess_word[4] == puzzle_word[3] : wrong_position += guess_word[4] puzzle_word = puzzle_word[0:4] + '&' else : wrong_position += "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0 : original_str = ch + original_str[1:5] elif k == 1 : original_str = original_str[0] + ch + original_str[2:5] elif k == 2 : original_str = original_str[0:2] + ch + original_str[3:5] elif k == 3 : original_str = original_str[0:3] + ch + original_str[4] elif k == 4 : original_str = original_str[0:4] + ch return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == 'green' : if 'A' <= text[0] <= 'Z' : ch1 = white_on_green + text[0] + normal else : ch1 = text[0] if 'A' <= text[1] <= 'Z' : ch2 = white_on_green + text[1] + normal else : ch2 = text[1] if 'A' <= text[2] <= 'Z' : ch3 = white_on_green + text[2] + normal else : ch3 = text[2] if 'A' <= text[3] <= 'Z' : ch4 = white_on_green + text[3] + normal else : ch4 = text[3] if 'A' <= text[4] <= 'Z' : ch5 = white_on_green + text[4] + normal else : ch5 = text[4] if color == 'yellow' : if 'A' <= text[0] <= 'Z' : ch1 = white_on_yellow + text[0] + normal else : ch1 = text[0] if 'A' <= text[1] <= 'Z' : ch2 = white_on_yellow + text[1] + normal else : ch2 = text[1] if 'A' <= text[2] <= 'Z' : ch3 = white_on_yellow + text[2] + normal else : ch3 = text[2] if 'A' <= text[3] <= 'Z' : ch4 = white_on_yellow + text[3] + normal else : ch4 = text[3] if 'A' <= text[4] <= 'Z' : ch5 = white_on_yellow + text[4] + normal else : ch5 = text[4] colored_text = ch1+ch2+ch3+ch4+ch5 return colored_text# 6432034221 sim = 75.88% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: correct += puzzle_word[0] new_puzzle_word = "-" + puzzle_word[1:] new_guess_word = "-" + new_guess_word[1:] else: correct += "?" if puzzle_word[1] == guess_word[1]: correct += puzzle_word[1] new_puzzle_word = new_puzzle_word[:1] + "-" + new_puzzle_word[2:] new_guess_word = new_guess_word[:1] + "-" + new_guess_word[2:] else: correct += "?" if puzzle_word[2] == guess_word[2]: correct += puzzle_word[2] new_puzzle_word = new_puzzle_word[:2] + "-" + new_puzzle_word[3:] new_guess_word = new_guess_word[:2] + "-" + new_guess_word[3:] else: correct += "?" if puzzle_word[3] == guess_word[3]: correct += puzzle_word[3] new_puzzle_word = new_puzzle_word[:3] + "-" + new_puzzle_word[4:] new_guess_word = new_guess_word[:3] + "-" + new_guess_word[4:] else: correct += "?" if puzzle_word[4] == guess_word[4]: correct += puzzle_word[4] new_puzzle_word = new_puzzle_word[:4] + "-" new_guess_word = new_guess_word[:4] + "-" else: correct += "?" return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != "-": wrong_position += guess_word[0] if guess_word[0] == puzzle_word[0]: puzzle_word = puzzle_word[:0]+"-"+puzzle_word[1:] elif guess_word[0] == puzzle_word[1]: puzzle_word = puzzle_word[:1]+"-"+puzzle_word[2:] elif guess_word[0] == puzzle_word[2]: puzzle_word = puzzle_word[:2]+"-"+puzzle_word[3:] elif guess_word[0] == puzzle_word[3]: puzzle_word = puzzle_word[:3]+"-"+puzzle_word[4:] elif guess_word[0] == puzzle_word[4]: puzzle_word = puzzle_word[:4]+"-"+puzzle_word[5:] else: wrong_position += "*" if guess_word[1] in puzzle_word and guess_word[1] != "-": wrong_position += guess_word[1] if guess_word[1] == puzzle_word[0]: puzzle_word = puzzle_word[:0]+"-"+puzzle_word[1:] elif guess_word[1] == puzzle_word[1]: puzzle_word = puzzle_word[:1]+"-"+puzzle_word[2:] elif guess_word[1] == puzzle_word[2]: puzzle_word = puzzle_word[:2]+"-"+puzzle_word[3:] elif guess_word[1] == puzzle_word[3]: puzzle_word = puzzle_word[:3]+"-"+puzzle_word[4:] elif guess_word[1] == puzzle_word[4]: puzzle_word = puzzle_word[:4]+"-"+puzzle_word[5:] else: wrong_position += "*" if guess_word[2] in puzzle_word and guess_word[2] != "-": wrong_position += guess_word[2] if guess_word[2] == puzzle_word[0]: puzzle_word = puzzle_word[:0]+"-"+puzzle_word[1:] elif guess_word[2] == puzzle_word[1]: puzzle_word = puzzle_word[:1]+"-"+puzzle_word[2:] elif guess_word[2] == puzzle_word[2]: puzzle_word = puzzle_word[:2]+"-"+puzzle_word[3:] elif guess_word[2] == puzzle_word[3]: puzzle_word = puzzle_word[:3]+"-"+puzzle_word[4:] elif guess_word[2] == puzzle_word[4]: puzzle_word = puzzle_word[:4]+"-"+puzzle_word[5:] else: wrong_position += "*" if guess_word[3] in puzzle_word and guess_word[3] != "-": wrong_position += guess_word[3] if guess_word[3] == puzzle_word[0]: puzzle_word = puzzle_word[:0]+"-"+puzzle_word[1:] elif guess_word[3] == puzzle_word[1]: puzzle_word = puzzle_word[:1]+"-"+puzzle_word[2:] elif guess_word[3] == puzzle_word[2]: puzzle_word = puzzle_word[:2]+"-"+puzzle_word[3:] elif guess_word[3] == puzzle_word[3]: puzzle_word = puzzle_word[:3]+"-"+puzzle_word[4:] elif guess_word[3] == puzzle_word[4]: puzzle_word = puzzle_word[:4]+"-"+puzzle_word[5:] else: wrong_position += "*" if guess_word[4] in puzzle_word and guess_word[4] != "-": wrong_position += guess_word[4] if guess_word[4] == puzzle_word[0]: puzzle_word = puzzle_word[:0]+"-"+puzzle_word[1:] elif guess_word[4] == puzzle_word[1]: puzzle_word = puzzle_word[:1]+"-"+puzzle_word[2:] elif guess_word[4] == puzzle_word[2]: puzzle_word = puzzle_word[:2]+"-"+puzzle_word[3:] elif guess_word[4] == puzzle_word[3]: puzzle_word = puzzle_word[:3]+"-"+puzzle_word[4:] elif guess_word[4] == puzzle_word[4]: puzzle_word = puzzle_word[:4]+"-"+puzzle_word[5:] else: wrong_position += "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): new_str = original_str[:k] + ch + original_str[k+1:] return new_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if "?" in text[0] or "*" in text[0]: colored_text += text[0] else: if color == "green": colored_text += white_on_green + text[0] + normal elif color == "yellow": colored_text += white_on_yellow + text[0] + normal if "?" in text[1] or "*" in text[1]: colored_text += text[1] else: if color == "green": colored_text += white_on_green + text[1] + normal elif color == "yellow": colored_text += white_on_yellow + text[1] + normal if "?" in text[2] or "*" in text[2]: colored_text += text[2] else: if color == "green": colored_text += white_on_green + text[2] + normal elif color == "yellow": colored_text += white_on_yellow + text[2] + normal if "?" in text[3] or "*" in text[3]: colored_text += text[3] else: if color == "green": colored_text += white_on_green + text[3] + normal elif color == "yellow": colored_text += white_on_yellow + text[3] + normal if "?" in text[4] or "*" in text[4]: colored_text += text[4] else: if color == "green": colored_text += white_on_green + text[4] + normal elif color == "yellow": colored_text += white_on_yellow + text[4] + normal return colored_text# 6432149821 sim = 75.63% import random import string def position_in_word(ch, word): if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_guess_word = '-' + guess_word[1:] new_puzzle_word = '-' + puzzle_word[1:] correct += guess_word[0] else: correct += '?' if guess_word[1] == puzzle_word[1]: new_guess_word = new_guess_word[0] + '-' + new_guess_word[2:] new_puzzle_word = new_puzzle_word[0] + '-' + new_puzzle_word[2:] correct += guess_word[1] else: correct += '?' if guess_word[2] == puzzle_word[2]: new_guess_word = new_guess_word[0] + new_guess_word[1] + '-' + new_guess_word[3:] new_puzzle_word = new_puzzle_word[0] + new_puzzle_word[1] + '-' + new_puzzle_word[3:] correct += guess_word[2] else: correct += '?' if guess_word[3] == puzzle_word[3]: new_guess_word = new_guess_word[0] + new_guess_word[1] + new_guess_word[2] + '-' + new_guess_word[4:] new_puzzle_word = new_puzzle_word[0] + new_puzzle_word[1] + new_puzzle_word[2] + '-' + new_puzzle_word[4:] correct += guess_word[3] else: correct += '?' if guess_word[4] == puzzle_word[4]: new_guess_word = new_guess_word[0] + new_guess_word[1] + new_guess_word[2] + new_guess_word[3] + '-' new_puzzle_word = new_puzzle_word[0] + new_puzzle_word[1] + new_puzzle_word[2] + new_puzzle_word[3] + '-' correct += guess_word[4] else: correct += '?' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word: if guess_word[0] == puzzle_word[0]: wrong_position += '*' elif guess_word[0] == puzzle_word[1]: wrong_position += guess_word[0] puzzle_word = puzzle_word[0] +' '+ puzzle_word[2:] elif guess_word[0] == puzzle_word[2]: wrong_position += guess_word[0] puzzle_word = puzzle_word[0:2] +' '+ puzzle_word[3:] elif guess_word[0] == puzzle_word[3]: wrong_position += guess_word[0] puzzle_word = puzzle_word[0:3] +' '+ puzzle_word[4:] elif guess_word[0] == puzzle_word[4]: wrong_position += guess_word[0] puzzle_word = puzzle_word[0:4] +' ' else: wrong_position += '*' if guess_word[1] in puzzle_word: if guess_word[1] == puzzle_word[1]: wrong_position += '*' elif guess_word[1] == puzzle_word[0]: wrong_position += guess_word[1] puzzle_word = ' '+ puzzle_word[1:] elif guess_word[1] == puzzle_word[2]: wrong_position += guess_word[1] puzzle_word = puzzle_word[0:2] +' '+ puzzle_word[3:] elif guess_word[1] == puzzle_word[3]: wrong_position += guess_word[1] puzzle_word = puzzle_word[0:3] +' '+ puzzle_word[4:] elif guess_word[1] == puzzle_word[4]: wrong_position += guess_word[1] puzzle_word = puzzle_word[0:4] +' ' else: wrong_position += '*' if guess_word[2] in puzzle_word: if guess_word[2] == puzzle_word[2]: wrong_position += '*' elif guess_word[2] == puzzle_word[0]: wrong_position += guess_word[2] puzzle_word = ' '+ puzzle_word[1:] elif guess_word[2] == puzzle_word[1]: wrong_position += guess_word[2] puzzle_word = puzzle_word[0] +' '+ puzzle_word[2:] elif guess_word[2] == puzzle_word[3]: wrong_position += guess_word[2] puzzle_word = puzzle_word[0:3] +' '+ puzzle_word[4:] elif guess_word[2] == puzzle_word[4]: wrong_position += guess_word[2] puzzle_word = puzzle_word[0:4] +' ' else: wrong_position += '*' if guess_word[3] in puzzle_word: if guess_word[3] == puzzle_word[3]: wrong_position += '*' elif guess_word[3] == puzzle_word[0]: wrong_position += guess_word[3] puzzle_word = ' '+ puzzle_word[1:] elif guess_word[3] == puzzle_word[1]: wrong_position += guess_word[3] puzzle_word = puzzle_word[0] +' '+ puzzle_word[2:] elif guess_word[3] == puzzle_word[2]: wrong_position += guess_word[3] puzzle_word = puzzle_word[0:2] +' '+ puzzle_word[3:] elif guess_word[3] == puzzle_word[4]: wrong_position += guess_word[3] puzzle_word = puzzle_word[0:4] +' ' else: wrong_position += '*' if guess_word[4] in puzzle_word: if guess_word[4] == puzzle_word[4]: wrong_position += '*' elif guess_word[4] == puzzle_word[0]: wrong_position += guess_word[4] puzzle_word = ' '+ puzzle_word[1:] elif guess_word[4] == puzzle_word[1]: wrong_position += guess_word[4] puzzle_word = puzzle_word[0] +' '+ puzzle_word[2:] elif guess_word[4] == puzzle_word[2]: wrong_position += guess_word[4] puzzle_word = puzzle_word[0:2] +' '+ puzzle_word[3:] elif guess_word[4] == puzzle_word[3]: wrong_position += guess_word[4] puzzle_word = puzzle_word[0:3] +' '+ puzzle_word[4:] else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0: original_str = ch + original_str[1:] elif k == 1: original_str = original_str[0] + ch + original_str[2:] elif k == 2: original_str = original_str[0:2] + ch + original_str[3:] elif k == 3: original_str = original_str[0:3] + ch + original_str[4:] elif k == 4: original_str = original_str[0:4] + ch return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if 'A' <= text[0] <= 'Z': if color == 'green': ch0 = white_on_green + text[0] + normal elif color == 'yellow': ch0 = white_on_yellow + text[0] + normal else: ch0 = text[0] if 'A' <= text[1] <= 'Z': if color == 'green': ch1 = white_on_green + text[1] + normal elif color == 'yellow': ch1 = white_on_yellow + text[1] + normal else: ch1 = text[1] if 'A' <= text[2] <= 'Z': if color == 'green': ch2 = white_on_green + text[2] + normal elif color == 'yellow': ch2 = white_on_yellow + text[2] + normal else: ch2 = text[2] if 'A' <= text[3] <= 'Z': if color == 'green': ch3 = white_on_green + text[3] + normal elif color == 'yellow': ch3 = white_on_yellow + text[3] + normal else: ch3 = text[3] if 'A' <= text[4] <= 'Z': if color == 'green': ch4 = white_on_green + text[4] + normal elif color == 'yellow': ch4 = white_on_yellow + text[4] + normal else: ch4 = text[4] text = ch0 + ch1 + ch2 + ch3 + ch4 colored_text = text return colored_text# 6430231121 sim = 74.51% import random import string def position_in_word(ch, word): if ch==word[0]: position=0 elif ch==word[1]: position=1 elif ch==word[2]: position=2 elif ch==word[3]: position=3 elif ch==word[4]: position=4 else: position=-1 return position def check_correct_position(puzzle_word, guess_word): correct = '' new_puzzle_word = '' new_guess_word='' if puzzle_word[0]==guess_word[0]: new_guess_word+='-' correct+=puzzle_word[0] new_puzzle_word += '-' else: new_guess_word+=guess_word[0] correct+='?' new_puzzle_word += puzzle_word[0] if puzzle_word[1]==guess_word[1]: new_guess_word+='-' correct+=puzzle_word[1] new_puzzle_word += '-' else: new_guess_word+=guess_word[1] correct+='?' new_puzzle_word += puzzle_word[1] if puzzle_word[2]==guess_word[2]: new_guess_word+='-' correct+=puzzle_word[2] new_puzzle_word += '-' else: new_guess_word+=guess_word[2] correct+='?' new_puzzle_word += puzzle_word[2] if puzzle_word[3]==guess_word[3]: new_guess_word+='-' correct+=puzzle_word[3] new_puzzle_word += '-' else: new_guess_word+=guess_word[3] correct+='?' new_puzzle_word += puzzle_word[3] if puzzle_word[4]==guess_word[4]: new_guess_word+='-' correct+=puzzle_word[4] new_puzzle_word += '-' else: new_guess_word+=guess_word[4] correct+='?' new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] == "-": wrong_position+='*' elif guess_word[0] == puzzle_word[1]: wrong_position += guess_word[0] puzzle_word= puzzle_word[0:1]+'*'+puzzle_word[2:5] elif guess_word[0] == puzzle_word[2]: wrong_position += guess_word[0] puzzle_word= puzzle_word[0:2]+'*'+puzzle_word[3:5] elif guess_word[0] == puzzle_word[3]: wrong_position += guess_word[0] puzzle_word= puzzle_word[0:3]+'*'+puzzle_word[4:5] elif guess_word[0] == puzzle_word[4]: wrong_position += guess_word[0] puzzle_word= puzzle_word[0:4]+'*' else: wrong_position = '*'+wrong_position[1:5] if guess_word[1] == "-": wrong_position+='*' elif guess_word[1] == puzzle_word[0]: wrong_position += guess_word[1] puzzle_word = '*'+puzzle_word[1:5] elif guess_word[1] == puzzle_word[2]: wrong_position += guess_word[1] puzzle_word= puzzle_word[0:2]+'*'+puzzle_word[3:5] elif guess_word[1] == puzzle_word[3]: wrong_position += guess_word[1] puzzle_word= puzzle_word[0:3]+'*'+puzzle_word[4:5] elif guess_word[1] == puzzle_word[4]: wrong_position += guess_word[1] puzzle_word= puzzle_word[0:4]+'*' else: wrong_position = wrong_position[0]+'*'+wrong_position[2:5] if guess_word[2] == "-": wrong_position+='*' elif guess_word[2] == puzzle_word[0]: wrong_position += guess_word[2] puzzle_word = '*'+puzzle_word[1:5] elif guess_word[2] == puzzle_word[1]: wrong_position += guess_word[2] puzzle_word= puzzle_word[0]+'*'+puzzle_word[2:5] elif guess_word[2] == puzzle_word[3]: wrong_position += guess_word[2] puzzle_word= puzzle_word[0:3]+'*'+puzzle_word[4:5] elif guess_word[2] == puzzle_word[4]: wrong_position += guess_word[2] puzzle_word= puzzle_word[0:4]+'*' else: wrong_position = wrong_position[0:2]+'*'+wrong_position[3:5] if guess_word[3] == "-": wrong_position+='*' elif guess_word[3] == puzzle_word[0]: wrong_position += guess_word[3] puzzle_word = '*'+puzzle_word[1:5] elif guess_word[3] == puzzle_word[1]: wrong_position += guess_word[3] puzzle_word= puzzle_word[0]+'*'+puzzle_word[2:5] elif guess_word[3] == puzzle_word[2]: wrong_position += guess_word[3] puzzle_word= puzzle_word[0:2]+'*'+puzzle_word[3:5] elif guess_word[3] == puzzle_word[4]: wrong_position += guess_word[3] puzzle_word= puzzle_word[0:4]+'*' else: wrong_position = wrong_position[0:3]+'*'+wrong_position[4:5] if guess_word[4] == "-": wrong_position+='*' elif guess_word[4] == puzzle_word[0]: wrong_position += guess_word[4] puzzle_word = '*'+puzzle_word[1:5] elif guess_word[4] == puzzle_word[1]: wrong_position += guess_word[4] puzzle_word= puzzle_word[0]+'*'+puzzle_word[2:5] elif guess_word[4] == puzzle_word[2]: wrong_position += guess_word[4] puzzle_word= puzzle_word[0:2]+'*'+puzzle_word[3:5] elif guess_word[4] == puzzle_word[3]: wrong_position += guess_word[4] puzzle_word= puzzle_word[0:3]+'*'+puzzle_word[4:5] else: wrong_position = wrong_position[0:4]+'*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): a=original_str[0:k]+ch+original_str[k+1:] return a def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if 'A'<=text[0]<='Z': if color=='green': ch01= white_on_green+ text[0] + normal elif color=='yellow': ch01= '\033[34;43m'+ text[0] + '\033[0;0m' else: ch01=text[0] if 'A'<=text[1]<='Z': if color=='green': ch02= '\033[37;42m'+ text[1] + '\033[0;0m' elif color=='yellow': ch02= '\033[34;43m'+ text[1] + '\033[0;0m' else: ch02=text[1] if 'A'<=text[2]<='Z': if color=='green': ch03= '\033[37;42m'+ text[2] + '\033[0;0m' elif color=='yellow': ch03= '\033[34;43m'+ text[2] + '\033[0;0m' else: ch03=text[2] if 'A'<=text[3]<='Z': if color=='green': ch04= '\033[37;42m'+ text[3] + '\033[0;0m' elif color=='yellow': ch04= '\033[34;43m'+ text[3] + '\033[0;0m' else: ch04=text[3] if 'A'<=text[4]<='Z': if color=='green': ch05= '\033[37;42m'+ text[4] + '\033[0;0m' elif color=='yellow': ch05= '\033[34;43m'+ text[4] + '\033[0;0m' else: ch05=text[4] colored_text += ch01+ch02+ch03+ch04+ch05 return colored_text# 6430423321 sim = 74.15% import random import string def position_in_word(ch, word): if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word= guess_word correct = '?????' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_guess_word= '-'+new_guess_word[1:] correct= puzzle_word[0]+correct[1:] new_puzzle_word= '-'+new_puzzle_word[1:] if guess_word[1] == puzzle_word[1]: new_guess_word= new_guess_word[0]+'-'+new_guess_word[2:] correct = correct[0]+puzzle_word[1]+correct[2:] new_puzzle_word= new_puzzle_word[0]+'-'+new_puzzle_word[2:] if guess_word[2] == puzzle_word[2]: new_guess_word= new_guess_word[0:2]+'-'+new_guess_word[3:] correct = correct[0:2]+puzzle_word[2]+correct[3:] new_puzzle_word= new_puzzle_word[0:2]+'-'+new_puzzle_word[3:] if guess_word[3] == puzzle_word[3]: new_guess_word= new_guess_word[0:3]+'-'+new_guess_word[4:] correct = correct[0:3]+puzzle_word[3]+correct[4:] new_puzzle_word= new_puzzle_word[0:3]+'-'+new_puzzle_word[4:] if guess_word[4] == puzzle_word[4]: new_guess_word= new_guess_word[0:4]+'-' correct = correct[0:4]+puzzle_word[4] new_puzzle_word= new_puzzle_word[0:4]+'-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] == puzzle_word[1]: wrong_position= guess_word[0]+wrong_position[1:] puzzle_word= puzzle_word[0:1]+'*'+puzzle_word[2:] elif guess_word[0] == puzzle_word[2]: wrong_position= guess_word[0]+wrong_position[1:] puzzle_word= puzzle_word[0:2]+'*'+puzzle_word[3:] elif guess_word[0] == puzzle_word[3]: wrong_position= guess_word[0]+wrong_position[1:] puzzle_word= puzzle_word[0:3]+'*'+puzzle_word[4:] elif guess_word[0] == puzzle_word[4]: wrong_position= guess_word[0]+wrong_position[1:] puzzle_word= puzzle_word[0:4]+'*' if guess_word[1] == puzzle_word[0]: wrong_position= wrong_position[0:1]+guess_word[1]+wrong_position[2:] puzzle_word= '*'+puzzle_word[1:] elif guess_word[1] == puzzle_word[2]: wrong_position= wrong_position[0:1]+guess_word[1]+wrong_position[2:] puzzle_word= puzzle_word[0:2]+'*'+puzzle_word[3:] elif guess_word[1] == puzzle_word[3]: wrong_position= wrong_position[0:1]+guess_word[1]+wrong_position[2:] puzzle_word= puzzle_word[0:3]+'*'+puzzle_word[4:] elif guess_word[1] == puzzle_word[4]: wrong_position= wrong_position[0:1]+guess_word[1]+wrong_position[2:] puzzle_word= puzzle_word[0:4]+'*' if guess_word[2] == puzzle_word[0]: wrong_position= wrong_position[0:2]+guess_word[2]+wrong_position[3:] puzzle_word= '*'+puzzle_word[1:] elif guess_word[2] == puzzle_word[1]: wrong_position= wrong_position[0:2]+guess_word[2]+wrong_position[3:] puzzle_word= puzzle_word[0:1]+'*'+puzzle_word[2:] elif guess_word[2] == puzzle_word[3]: wrong_position= wrong_position[0:2]+guess_word[2]+wrong_position[3:] puzzle_word= puzzle_word[0:3]+'*'+puzzle_word[4:] elif guess_word[2] == puzzle_word[4]: wrong_position= wrong_position[0:2]+guess_word[2]+wrong_position[3:] puzzle_word= puzzle_word[0:4]+'*' if guess_word[3] == puzzle_word[0]: wrong_position= wrong_position[0:3]+guess_word[3]+wrong_position[4:] puzzle_word= '*'+puzzle_word[1:] elif guess_word[3] == puzzle_word[1]: wrong_position= wrong_position[0:3]+guess_word[3]+wrong_position[4:] puzzle_word= puzzle_word[0:1]+'*'+puzzle_word[2:] elif guess_word[3] == puzzle_word[2]: wrong_position= wrong_position[0:3]+guess_word[3]+wrong_position[4:] puzzle_word= puzzle_word[0:2]+'*'+puzzle_word[3:] elif guess_word[3] == puzzle_word[4]: wrong_position= wrong_position[0:3]+guess_word[3]+wrong_position[4:] puzzle_word= puzzle_word[0:4]+'*' if guess_word[4] == puzzle_word[0]: wrong_position= wrong_position[0:4]+guess_word[4] puzzle_word= '*'+puzzle_word[1:] elif guess_word[4] == puzzle_word[1]: wrong_position= wrong_position[0:4]+guess_word[4] puzzle_word= puzzle_word[0:1]+'*'+puzzle_word[2:] elif guess_word[4] == puzzle_word[2]: wrong_position= wrong_position[0:4]+guess_word[4] puzzle_word= puzzle_word[0:2]+'*'+puzzle_word[3:] elif guess_word[4] == puzzle_word[3]: wrong_position= wrong_position[0:4]+guess_word[4] puzzle_word= puzzle_word[0:3]+'*'+puzzle_word[4:] if wrong_position[0] =="-" : wrong_position= '*'+wrong_position[1:] if wrong_position[1] =="-" : wrong_position= wrong_position[0] + '*' + wrong_position[2:] if wrong_position[2] =="-" : wrong_position= wrong_position[0:2] + '*' + wrong_position[3:] if wrong_position[3] =="-" : wrong_position= wrong_position[0:3] + '*' + wrong_position[4:] if wrong_position[4] =="-" : wrong_position= wrong_position[0:4] + '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): re_kth= original_str if k==0: re_kth= ch+original_str[1:] elif k==1: re_kth= original_str[0:1]+ch+original_str[2:] elif k==2: re_kth= original_str[0:2]+ch+original_str[3:] elif k==3: re_kth= original_str[0:3]+ch+original_str[4:] elif k==4: re_kth= original_str[0:4]+ch return re_kth def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text if color== 'green': if 'A'<=text[0]<='Z' : ch1= white_on_green + text[0] + normal else: ch1=text[0] if 'A'<=text[1]<='Z' : ch2= white_on_green + text[1] + normal else: ch2=text[1] if 'A'<=text[2]<='Z' : ch3= white_on_green + text[2] + normal else: ch3=text[2] if 'A'<=text[3]<='Z' : ch4= white_on_green + text[3] + normal else: ch4=text[3] if 'A'<=text[4]<='Z' : ch5= white_on_green + text[4] + normal else: ch5=text[4] colored_text= ch1 + ch2 + ch3 + ch4 + ch5 if color== 'yellow': if 'A'<=text[0]<='Z' : ch1= white_on_yellow + text[0] + normal else: ch1=text[0] if 'A'<=text[1]<='Z' : ch2= white_on_yellow + text[1] + normal else: ch2=text[1] if 'A'<=text[2]<='Z' : ch3= white_on_yellow + text[2] + normal else: ch3=text[2] if 'A'<=text[3]<='Z' : ch4= white_on_yellow + text[3] + normal else: ch4=text[3] if 'A'<=text[4]<='Z' : ch5= white_on_yellow + text[4] + normal else: ch5=text[4] colored_text= ch1 + ch2 + ch3 + ch4 + ch5 return colored_text# 6430220221 sim = 72.74% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: correct = puzzle_word[0] + correct[1:] guess_word = '-' + guess_word[1:] puzzle_word = '-' + puzzle_word[1:] new_guess_word = guess_word new_puzzle_word = puzzle_word if guess_word[1] == puzzle_word[1]: correct = correct[0] + puzzle_word[1] + correct[2:] guess_word = guess_word[0] + '-' + guess_word[2:] puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] new_guess_word = guess_word new_puzzle_word = puzzle_word if guess_word[2] == puzzle_word[2]: correct = correct[:2] + puzzle_word[2] + correct[3:] guess_word = guess_word[:2] + '-' + guess_word[3:] puzzle_word = puzzle_word[:2] + '-' + puzzle_word[3:] new_guess_word = guess_word new_puzzle_word = puzzle_word if guess_word[3] == puzzle_word[3]: correct = correct[:3] + puzzle_word[3] + correct[4] guess_word = guess_word[:3] + '-' + guess_word[4] puzzle_word = puzzle_word[:3] + '-' + puzzle_word[4] new_guess_word = guess_word new_puzzle_word = puzzle_word if guess_word[4] == puzzle_word[4]: correct = correct[:4] + puzzle_word[4] guess_word = guess_word[:4] + '-' puzzle_word = puzzle_word[:4] + '-' new_guess_word = guess_word new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] in puzzle_word and guess_word[0] != '-': wrong_position = guess_word[0] + wrong_position[1:] if guess_word[0] == puzzle_word[1]: puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] elif guess_word[0] == puzzle_word[2]: puzzle_word = puzzle_word[:2] + '-' + puzzle_word[3:] elif guess_word[0] == puzzle_word[3]: puzzle_word = puzzle_word[:3] + '-' + puzzle_word[4] elif guess_word[0] == puzzle_word[4]: puzzle_word = puzzle_word[:4] + '-' if guess_word[1] in puzzle_word and guess_word[1] != '-': wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] if guess_word[1] == puzzle_word[0]: puzzle_word = '-' + puzzle_word[1:] elif guess_word[1] == puzzle_word[2]: puzzle_word = puzzle_word[:2] + '-' + puzzle_word[3:] elif guess_word[1] == puzzle_word[3]: puzzle_word = puzzle_word[:3] + '-' + puzzle_word[4] elif guess_word[1] == puzzle_word[4]: puzzle_word = puzzle_word[:4] + '-' if guess_word[2] in puzzle_word and guess_word[2] != '-': wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] if guess_word[2] == puzzle_word[0]: puzzle_word = '-' + puzzle_word[1:] elif guess_word[2] == puzzle_word[1]: puzzle_word = puzzle_word[:1] + '-' + puzzle_word[2:] elif guess_word[2] == puzzle_word[3]: puzzle_word = puzzle_word[:3] + '-' + puzzle_word[4] elif guess_word[2] == puzzle_word[4]: puzzle_word = puzzle_word[:4] + '-' if guess_word[3] in puzzle_word and guess_word[3] != '-': wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4] if guess_word[3] == puzzle_word[0]: puzzle_word = '-' + puzzle_word[1:] elif guess_word[3] == puzzle_word[1]: puzzle_word = puzzle_word[:1] + '-' + puzzle_word[2:] elif guess_word[3] == puzzle_word[2]: puzzle_word = puzzle_word[:2] + '-' + puzzle_word[3:] elif guess_word[3] == puzzle_word[4]: puzzle_word = puzzle_word[:4] + '-' if guess_word[4] in puzzle_word and guess_word[4] != '-': wrong_position = wrong_position[:4] + guess_word[4] if guess_word[4] == puzzle_word[0]: puzzle_word = '-' + puzzle_word[1:] elif guess_word[4] == puzzle_word[1]: puzzle_word = puzzle_word[:1] + '-' + puzzle_word[2:] elif guess_word[4] == puzzle_word[2]: puzzle_word = puzzle_word[:2] + '-' + puzzle_word[3:] elif guess_word[4] == puzzle_word[3]: puzzle_word = puzzle_word[:4] + '-' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0: original_str = ch + original_str[1:] if k == 1: original_str = original_str[0] + ch + original_str[2:] if k == 2: original_str = original_str[:2] + ch + original_str[3:] if k == 3: original_str = original_str[:3] + ch + original_str[4:] if k == 4: original_str = original_str[:4] + ch return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text[0] not in '?*': if color == 'green': colored_text += white_on_green + text[0] + normal elif color == 'yellow': colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if text[1] not in '?*': if color == 'green': colored_text += white_on_green + text[1] + normal elif color == 'yellow': colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if text[2] not in '?*': if color == 'green': colored_text += white_on_green + text[2] + normal elif color == 'yellow': colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if text[3] not in '?*': if color == 'green': colored_text += white_on_green + text[3] + normal elif color == 'yellow': colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if text[4] not in '?*': if color == 'green': colored_text += white_on_green + text[4] + normal elif color == 'yellow': colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text# 6432010121 sim = 72.61% import random import string def position_in_word(ch, word): position = -1 if ch==word[0]: position=0 elif ch==word[1]: position=1 elif ch==word[2]: position=2 elif ch==word[3]: position=3 elif ch==word[4]: position=4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if puzzle_word[0]==guess_word[0]: new_guess_word = '-'+new_guess_word[1:] correct = puzzle_word[0]+correct[1:] new_puzzle_word = '-'+new_puzzle_word[1:] if puzzle_word[1]==guess_word[1]: new_guess_word = new_guess_word[0] + '-' + new_guess_word[2:] correct = correct[0] + puzzle_word[1] + correct[2:] new_puzzle_word = new_puzzle_word[0] + '-' + new_puzzle_word[2:] if puzzle_word[2]==guess_word[2]: new_guess_word = new_guess_word[0:2] + '-' + new_guess_word[3:] correct = correct[0:2] + puzzle_word[2] + correct[3:] new_puzzle_word = new_puzzle_word[0:2] + '-' + new_puzzle_word[3:] if puzzle_word[3]==guess_word[3]: new_guess_word = new_guess_word[0:3] + '-' + new_guess_word[4] correct = correct[0:3] + puzzle_word[3] + correct[4] new_puzzle_word = new_puzzle_word[0:3] + '-' + new_puzzle_word[4] if puzzle_word[4]==guess_word[4]: new_guess_word = new_guess_word[0:4] + '-' correct = correct[0:4] + puzzle_word[4] new_puzzle_word = new_puzzle_word[0:4] + '-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if 'a'<=guess_word[0]<='z' or 'A'<=guess_word[0]<='Z' : if guess_word[0]==puzzle_word[1]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[0]+'-'+puzzle_word[2:] elif guess_word[0]==puzzle_word[2]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[0:2]+'-'+puzzle_word[3:] elif guess_word[0]==puzzle_word[3]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[0:3]+'-'+puzzle_word[4] elif guess_word[0]==puzzle_word[4]: wrong_position = guess_word[0] + wrong_position[1:] puzzle_word = puzzle_word[0:4]+'-' if 'a'<=guess_word[1]<='z' or 'A'<=guess_word[1]<='Z' : if guess_word[1]==puzzle_word[0]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = '-'+puzzle_word[1:] elif guess_word[1]==puzzle_word[2]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[0:2]+'-'+puzzle_word[3:] elif guess_word[1]==puzzle_word[3]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[0:3]+'-'+puzzle_word[4] elif guess_word[1]==puzzle_word[4]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] puzzle_word = puzzle_word[0:4]+'-' if 'a'<=guess_word[2]<='z' or 'A'<=guess_word[2]<='Z' : if guess_word[2]==puzzle_word[0]: wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:] puzzle_word = '-'+puzzle_word[1:] elif guess_word[2]==puzzle_word[1]: wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[0]+'-'+puzzle_word[2:] elif guess_word[2]==puzzle_word[3]: wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[0:3]+'-'+puzzle_word[4] elif guess_word[2]==puzzle_word[4]: wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:] puzzle_word = puzzle_word[0:4]+'-' if 'a'<=guess_word[3]<='z' or 'A'<=guess_word[3]<='Z' : if guess_word[3]==puzzle_word[0]: wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4] puzzle_word = '-'+puzzle_word[1:] elif guess_word[3]==puzzle_word[1]: wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4] puzzle_word = puzzle_word[0]+'-'+puzzle_word[2:] elif guess_word[3]==puzzle_word[2]: wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4] puzzle_word = puzzle_word[0:2]+'-'+puzzle_word[3:] elif guess_word[3]==puzzle_word[4]: wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4] puzzle_word = puzzle_word[0:4]+'-' if 'a'<=guess_word[4]<='z' or 'A'<=guess_word[4]<='Z' : if guess_word[4]==puzzle_word[0]: wrong_position = wrong_position[0:4] + guess_word[4] puzzle_word = '-'+puzzle_word[1:] elif guess_word[4]==puzzle_word[1]: wrong_position = wrong_position[0:4] + guess_word[4] puzzle_word = puzzle_word[0]+'-'+puzzle_word[2:] elif guess_word[4]==puzzle_word[2]: wrong_position = wrong_position[0:4] + guess_word[4] puzzle_word = puzzle_word[0:2]+'-'+puzzle_word[3:] elif guess_word[4]==puzzle_word[3]: wrong_position = wrong_position[0:4] + guess_word[4] puzzle_word = puzzle_word[0:3]+'-'+puzzle_word[4] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): ns=original_str if k==0 : ns = ch + ns[1:] elif k==1 : ns = ns[0] + ch + ns[2:] elif k==2 : ns = ns[0:2] + ch + ns[3:] elif k==3 : ns = ns[0:3] + ch + ns[4] elif k==4 : ns = ns[0:4] + ch return ns def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' text = [text[0],text[1],text[2],text[3],text[4]] if 'A'<=text[0]<='Z' : if color=='green': text[0] = (white_on_green+text[0]+normal) elif color=='yellow': text[0] = (white_on_yellow+text[0]+normal) if 'A'<=text[1]<='Z' : if color=='green': text[1] = (white_on_green+text[1]+normal) elif color=='yellow': text[1] = (white_on_yellow+text[1]+normal) if 'A'<=text[2]<='Z' : if color=='green': text[2] = (white_on_green+text[2]+normal) elif color=='yellow': text[2] = (white_on_yellow+text[2]+normal) if 'A'<=text[3]<='Z' : if color=='green': text[3] = (white_on_green+text[3]+normal) elif color=='yellow': text[3] = (white_on_yellow+text[3]+normal) if 'A'<=text[4]<='Z' : if color=='green': text[4] = (white_on_green+text[4]+normal) elif color=='yellow': text[4] = (white_on_yellow+text[4]+normal) text = text[0]+text[1]+text[2]+text[3]+text[4] colored_text = text return colored_text# 6430342121 sim = 71.93% import random import string def position_in_word(ch, word): if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = "" new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_guess_word = "-" + new_guess_word[1:] correct += puzzle_word[0] new_puzzle_word = "-" + new_puzzle_word[1:] else: correct += "?" if guess_word[1] == puzzle_word[1]: new_guess_word = new_guess_word[0] + "-" + new_guess_word[2:] correct += puzzle_word[1] new_puzzle_word = new_puzzle_word[0] + "-" + new_puzzle_word[2:] else: correct += "?" if guess_word[2] == puzzle_word[2]: new_guess_word = new_guess_word[:2] + "-" + new_guess_word[3:] correct += puzzle_word[2] new_puzzle_word = new_puzzle_word[:2] + "-" + new_puzzle_word[3:] else: correct += "?" if guess_word[3] == puzzle_word[3]: new_guess_word = new_guess_word[:3] + "-" + new_guess_word[4:] correct += puzzle_word[3] new_puzzle_word = new_puzzle_word[:3] + "-" + new_puzzle_word[4:] else: correct += "?" if guess_word[4] == puzzle_word[4]: new_guess_word = new_guess_word[:4] + "-" correct += puzzle_word[4] new_puzzle_word = new_puzzle_word[:4] + "-" else: correct += "?" return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = "" new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[1]: wrong_position += guess_word[0] new_puzzle_word = new_puzzle_word[0] + "-" + new_puzzle_word[2:] elif guess_word[0] == puzzle_word[2]: wrong_position += guess_word[0] new_puzzle_word = new_puzzle_word[:2] + "-" + new_puzzle_word[3:] elif guess_word[0] == puzzle_word[3]: wrong_position += guess_word[0] new_puzzle_word = new_puzzle_word[:3] + "-" + new_puzzle_word[4:] elif guess_word[0] == puzzle_word[4]: wrong_position += guess_word[0] new_puzzle_word = new_puzzle_word[:4] + "-" else: wrong_position += "*" if guess_word[1] == new_puzzle_word[0]: wrong_position += guess_word[1] new_puzzle_word = "-" + new_puzzle_word[1:] elif guess_word[1] == new_puzzle_word[2]: wrong_position += guess_word[1] new_puzzle_word = new_puzzle_word[:2] + "-" + new_puzzle_word[3:] elif guess_word[1] == new_puzzle_word[3]: wrong_position += guess_word[1] new_puzzle_word = new_puzzle_word[:3] + "-" + new_puzzle_word[4:] elif guess_word[1] == new_puzzle_word[4]: wrong_position += guess_word[1] new_puzzle_word = new_puzzle_word[:4] + "-" else: wrong_position += "*" if guess_word[2] == new_puzzle_word[0]: wrong_position += guess_word[2] new_puzzle_word = "-" + new_puzzle_word[1:] elif guess_word[2] == new_puzzle_word[1]: wrong_position += guess_word[2] new_puzzle_word = new_puzzle_word[0] + "-" + new_puzzle_word[2:] elif guess_word[2] == new_puzzle_word[3]: wrong_position += guess_word[2] new_puzzle_word = new_puzzle_word[:3] + "-" + new_puzzle_word[4:] elif guess_word[2] == new_puzzle_word[4]: wrong_position += guess_word[2] new_puzzle_word = new_puzzle_word[:4] + "-" else: wrong_position += "*" if guess_word[3] == new_puzzle_word[0]: wrong_position += guess_word[3] new_puzzle_word = "-" + new_puzzle_word[1:] elif guess_word[3] == new_puzzle_word[1]: wrong_position += guess_word[3] new_puzzle_word = new_puzzle_word[0] + "-" + new_puzzle_word[2:] elif guess_word[3] == new_puzzle_word[2]: wrong_position += guess_word[3] new_puzzle_word = new_puzzle_word[:2] + "-" + new_puzzle_word[3:] elif guess_word[3] == new_puzzle_word[4]: wrong_position += guess_word[3] new_puzzle_word = new_puzzle_word[:4] + "-" else: wrong_position += "*" if guess_word[4] == new_puzzle_word[0]: wrong_position += guess_word[4] new_puzzle_word = "-" + new_puzzle_word[1:] elif guess_word[4] == new_puzzle_word[1]: wrong_position += guess_word[4] new_puzzle_word = new_puzzle_word[0] + "-" + new_puzzle_word[2:] elif guess_word[4] == new_puzzle_word[2]: wrong_position += guess_word[4] new_puzzle_word = new_puzzle_word[:2] + "-" + new_puzzle_word[3:] elif guess_word[4] == new_puzzle_word[3]: wrong_position += guess_word[4] new_puzzle_word = new_puzzle_word[:3] + "-" + new_puzzle_word[4:] else: wrong_position += "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[0:k] + ch + original_str[k+1:5] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = "" if 65 <= ord(text[0]) <= 122: if color == "green": colored_text += white_on_green + text[0] + normal elif color == "yellow": colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if 65 <= ord(text[1]) <= 122: if color == "green": colored_text += white_on_green + text[1] + normal elif color == "yellow": colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if 65 <= ord(text[2]) <= 122: if color == "green": colored_text += white_on_green + text[2] + normal elif color == "yellow": colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if 65 <= ord(text[3]) <= 122: if color == "green": colored_text += white_on_green + text[3] + normal elif color == "yellow": colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if 65 <= ord(text[4]) <= 122: if color == "green": colored_text += white_on_green + text[4] + normal elif color == "yellow": colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text# 6430260321 sim = 70.71% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_guess_word = '-' + new_guess_word[1:] correct = guess_word[0] + '????' new_puzzle_word = '-' + new_puzzle_word[1:] if guess_word[1] == puzzle_word[1]: new_guess_word = new_guess_word[0] + '-' + new_guess_word[2:] correct = correct[0] + guess_word[1] + '???' new_puzzle_word = new_puzzle_word[0] + '-' + new_puzzle_word[2:] if guess_word[2] == puzzle_word[2]: new_guess_word = new_guess_word[0:2] + '-' + new_guess_word[3:] correct = correct[0:2] + guess_word[2] + '??' new_puzzle_word = new_puzzle_word[0:2] + '-' + new_puzzle_word[3:] if guess_word[3] == puzzle_word[3]: new_guess_word = new_guess_word[0:3] + '-' + new_guess_word[4:] correct = correct[0:3] + guess_word[3] + '?' new_puzzle_word = new_puzzle_word[0:3] + '-' + new_puzzle_word[4:] if guess_word[4] == puzzle_word[4]: new_guess_word = new_guess_word[0:4] + '-' correct = correct[0:4] + guess_word[4] new_puzzle_word = new_puzzle_word[0:4] + '-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*'*5 puzzle_check = puzzle_word if guess_word[0] in puzzle_check and guess_word[0] != puzzle_check[0]: wrong_position = guess_word[0] + '****' if guess_word[0] == puzzle_check[1]: puzzle_check = puzzle_check[0] + '-' + puzzle_check[2:] elif guess_word[0] == puzzle_check[2]: puzzle_check = puzzle_check[0:2] + '-' + puzzle_check[3:] elif guess_word[0] == puzzle_check[3]: puzzle_check = puzzle_check[0:3] + '-' + puzzle_check[4] elif guess_word[0] == puzzle_check[4]: puzzle_check = puzzle_check[0:4] + '-' if guess_word[1] in puzzle_check and guess_word[1] != puzzle_check[1] : wrong_position = wrong_position[0] + guess_word[1] + '***' if guess_word[1] == puzzle_check[0]: puzzle_check = '-' + puzzle_check[1:] elif guess_word[1] == puzzle_check[2]: puzzle_check = puzzle_check[0:2] + '-' + puzzle_check[3:] elif guess_word[1] == puzzle_check[3]: puzzle_check = puzzle_check[0:3] + '-' + puzzle_check[4] elif guess_word[1] == puzzle_check[4]: puzzle_check = puzzle_check[0:4] + '-' if guess_word[2] in puzzle_check and guess_word[2] != puzzle_check[2] : wrong_position = wrong_position[:2] + guess_word[2] + '**' if guess_word[2] == puzzle_check[0]: puzzle_check = '-' + puzzle_check[1:] elif guess_word[2] == puzzle_check[1]: puzzle_check = puzzle_check[0] + '-' + puzzle_check[2:] elif guess_word[2] == puzzle_check[3]: puzzle_check = puzzle_check[0:3] + '-' + puzzle_check[4] elif guess_word[2] == puzzle_check[4]: puzzle_check = puzzle_check[0:4] + '-' if guess_word[3] in puzzle_check and guess_word[3] != puzzle_check[3] : wrong_position = wrong_position[:3] + guess_word[3] + '*' if guess_word[3] == puzzle_check[0]: puzzle_check = '-' + puzzle_check[1:] elif guess_word[3] == puzzle_check[1]: puzzle_check = puzzle_check[0] + '-' + puzzle_check[2:] elif guess_word[3] == puzzle_check[2]: puzzle_check = puzzle_check[0:2] + '-' + puzzle_check[3:] elif guess_word[3] == puzzle_check[4]: puzzle_check = puzzle_check[0:4] + '-' if guess_word[4] in puzzle_check and guess_word[4] != puzzle_word[4] : wrong_position = wrong_position[:4] + guess_word[4] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[0:k] + ch + original_str[k+1:-1] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text[0] != '*' and text[0] != '?' : if color == 'yellow' : colored_text = white_on_yellow + text[0] + normal elif color == 'green' : colored_text = white_on_green + text[0] + normal else: colored_text = text[0] if text[1] != '*' and text[1] != '?' : if color == 'yellow' : colored_text += white_on_yellow + text[1] + normal elif color == 'green' : colored_text += white_on_green + text[1] + normal else: colored_text += text[1] if text[2] != '*' and text[2] != '?' : if color == 'yellow' : colored_text += white_on_yellow + text[2] + normal elif color == 'green' : colored_text += white_on_green + text[2] + normal else: colored_text += text[2] if text[3] != '*' and text[3] != '?' : if color == 'yellow' : colored_text += white_on_yellow + text[3] + normal elif color == 'green' : colored_text += white_on_green + text[3] + normal else: colored_text += text[3] if text[4] != '*' and text[4] != '?' : if color == 'yellow' : colored_text += white_on_yellow + text[4] + normal elif color == 'green' : colored_text += white_on_green + text[4] + normal else: colored_text += text[3] return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #6(2)

# 6430242021 sim = 83.95% import random import string def position_in_word(ch, word): if ch ==word[0]: position = 1 if ch ==word[1]: position = 2 if ch ==word[2]: position = 3 if ch ==word[3]: position = 4 if ch ==word[4]: position = 5 if ch not in word: position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = "?????" new_guess_word = guess_word new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_guess_word = replace_letter(guess_word, guess_word[0], "-") correct = list(correct) correct[0] = puzzle_word[0] correct = "".join(correct) new_puzzle_word = list(puzzle_word) new_puzzle_word[0] = "-" new_puzzle_word = "".join(new_puzzle_word) if guess_word[1] == puzzle_word[1]: new_guess_word = replace_letter(new_guess_word, new_guess_word[1], "-") correct = list(correct) correct[1] = puzzle_word[1] correct = "".join(correct) new_puzzle_word = list(new_puzzle_word) new_puzzle_word[1] = "-" new_puzzle_word = "".join(new_puzzle_word) if guess_word[2] == puzzle_word[2]: new_guess_word = replace_letter(new_guess_word, new_guess_word[2], "-") correct = list(correct) correct[2] = puzzle_word[2] correct = "".join(correct) new_puzzle_word = list(new_puzzle_word) new_puzzle_word[2] = "-" new_puzzle_word = "".join(new_puzzle_word) if guess_word[3] == puzzle_word[3]: new_guess_word = replace_letter(new_guess_word, new_guess_word[3], "-") correct = list(correct) correct[3] = puzzle_word[3] correct = "".join(correct) new_puzzle_word = list(new_puzzle_word) new_puzzle_word[3] = "-" new_puzzle_word = "".join(new_puzzle_word) if guess_word[4] == puzzle_word[4]: new_guess_word = replace_letter(new_guess_word, new_guess_word[4], "-") correct = list(correct) correct[4] = puzzle_word[4] correct = "".join(correct) new_puzzle_word = list(new_puzzle_word) new_puzzle_word[4] = "-" new_puzzle_word = "".join(new_puzzle_word) return new_guess_word, correct, new_puzzle_word def replace_letter(original, old_letter, new_letter): if old_letter in original: k = original.find(old_letter) original = original[:k] + new_letter + original[k+1:] return original def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if (guess_word[0]in puzzle_word)and("A"<=guess_word[0]<="Z") : wrong_position = list(wrong_position) wrong_position[0] = guess_word[0] wrong_position = "".join(wrong_position) puzzle_word=replace_letter(puzzle_word, guess_word[0], "*") if (guess_word[1]in puzzle_word)and("A"<=guess_word[1]<="Z") : wrong_position = list(wrong_position) wrong_position[1] = guess_word[1] wrong_position = "".join(wrong_position) puzzle_word=replace_letter(puzzle_word, guess_word[1], "*") if (guess_word[2]in puzzle_word)and("A"<=guess_word[2]<="Z") : wrong_position = list(wrong_position) wrong_position[2] = guess_word[2] wrong_position = "".join(wrong_position) puzzle_word=replace_letter(puzzle_word, guess_word[2], "*") if (guess_word[3]in puzzle_word)and("A"<=guess_word[3]<="Z") : wrong_position = list(wrong_position) wrong_position[3] = guess_word[3] wrong_position = "".join(wrong_position) puzzle_word=replace_letter(puzzle_word, guess_word[3], "*") if (guess_word[4]in puzzle_word)and("A"<=guess_word[4]<="Z") : wrong_position = list(wrong_position) wrong_position[4] = guess_word[4] wrong_position = "".join(wrong_position) puzzle_word=replace_letter(puzzle_word, guess_word[4], "*") return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k ==0: original_str = ch+original_str[1::] if k ==1: original_str = original_str[0]+ch+original_str[2::] if k ==2: original_str = original_str[0:2:]+ch+original_str[3::] if k ==3: original_str = original_str[0:3]+ch+original_str[4] if k ==4: original_str = original_str[0:4]+ch return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' ch0 = text[0] ch1 = text[1] ch2 = text[2] ch3 = text[3] ch4 = text[4] if color == 'yellow': if text[0] != "*": ch0 = white_on_yellow + text[0] + normal if text[1] != "*": ch1 = white_on_yellow + text[1] + normal if text[2] != "*": ch2 = white_on_yellow + text[2] + normal if text[3] != "*": ch3 = white_on_yellow + text[3] + normal if text[4] != "*": ch4 = white_on_yellow + text[4] + normal colored_text = ch0+ch1+ch2+ch3+ch4 if color == 'green': if text[0] != "?": ch0 = white_on_green + text[0] + normal if text[1] != "?": ch1 = white_on_green + text[1] + normal if text[2] != "?": ch2 = white_on_green + text[2] + normal if text[3] != "?": ch3 = white_on_green + text[3] + normal if text[4] != "?": ch4 = white_on_green + text[4] + normal colored_text = ch0+ch1+ch2+ch3+ch4 return colored_text# 6430252321 sim = 83.95% import random import string def position_in_word(ch, word): if ch == word[0]: position = 0 if ch == word[1]: position = 1 if ch == word[2]: position = 2 if ch == word[3]: position = 3 if ch == word[4]: position = 4 if ch not in word: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = "?????" new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_guess_word = replace_letter(guess_word,guess_word[0],"-") correct_list = list(correct) correct_list[0] = puzzle_word[0] correct = "".join(correct_list) new_puzzle_word = list(new_puzzle_word) new_puzzle_word[0] = "-" new_puzzle_word = "".join(new_puzzle_word) if guess_word[1] == puzzle_word[1]: new_guess_word = replace_letter(new_guess_word,new_guess_word[1],"-") correct_list = list(correct) correct_list[1] = puzzle_word[1] correct = "".join(correct_list) new_puzzle_word = list(new_puzzle_word) new_puzzle_word[1] = "-" new_puzzle_word = "".join(new_puzzle_word) if guess_word[2] == puzzle_word[2]: new_guess_word = replace_letter(new_guess_word,new_guess_word[2],"-") correct_list = list(correct) correct_list[2] = puzzle_word[2] correct = "".join(correct_list) new_puzzle_word = list(new_puzzle_word) new_puzzle_word[1] = "-" new_puzzle_word = "".join(new_puzzle_word) if guess_word[3] == puzzle_word[3]: new_guess_word = replace_letter(new_guess_word,new_guess_word[3],"-") correct_list = list(correct) correct_list[3] = puzzle_word[3] correct = "".join(correct_list) new_puzzle_word = list(new_puzzle_word) new_puzzle_word[3] = "-" new_puzzle_word = "".join(new_puzzle_word) if guess_word[4] == puzzle_word[4]: new_guess_word = replace_letter(new_guess_word,new_guess_word[4],"-") correct_list = list(correct) correct_list[4] = puzzle_word[4] correct = "".join(correct_list) new_puzzle_word = list(new_puzzle_word) new_puzzle_word[4] = "-" new_puzzle_word = "".join(new_puzzle_word) return new_guess_word, correct, new_puzzle_word def replace_letter(original, old_letter, new_letter): if old_letter in original: k = original.find(old_letter) original = original[:k] + new_letter + original[k+1:] return original def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if (guess_word[0] in puzzle_word) and ("A" <= guess_word[0] <= "Z") : list_wrong_position = list(wrong_position) list_wrong_position[0] = guess_word[0] wrong_position = "".join(list_wrong_position) puzzle_word = replace_letter(puzzle_word,guess_word[0],"-") if (guess_word[1] in puzzle_word) and ("A" <= guess_word[1] <= "Z") : list_wrong_position = list(wrong_position) list_wrong_position[1] = guess_word[1] wrong_position = "".join(list_wrong_position) puzzle_word = replace_letter(puzzle_word,guess_word[1],"-") if (guess_word[2] in puzzle_word) and ("A" <= guess_word[2] <= "Z") : list_wrong_position = list(wrong_position) list_wrong_position[2] = guess_word[2] wrong_position = "".join(list_wrong_position) puzzle_word = replace_letter(puzzle_word,guess_word[2],"-") if (guess_word[3] in puzzle_word) and ("A" <= guess_word[3] <= "Z") : list_wrong_position = list(wrong_position) list_wrong_position[3] = guess_word[3] wrong_position = "".join(list_wrong_position) puzzle_word = replace_letter(puzzle_word,guess_word[3],"-") if (guess_word[4] in puzzle_word) and ("A" <= guess_word[4] <= "Z") : list_wrong_position = list(wrong_position) list_wrong_position[4] = guess_word[4] wrong_position = "".join(list_wrong_position) puzzle_word = replace_letter(puzzle_word,guess_word[4],"-") return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0: replace_original_str = ch + original_str[1:] elif k == 1: replace_original_str = original_str[0] + ch + original_str[2:] elif k == 2: replace_original_str = original_str[0:2] + ch + original_str[3:] elif k == 3: replace_original_str = original_str[0:3] + ch + original_str[4:] elif k == 4: replace_original_str = original_str[0:4] + ch return 'replace_original_str' def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' ab0 = text[0] ab1 = text[1] ab2 = text[2] ab3 = text[3] ab4 = text[4] if color == "green": if text[0] != "?": ab0 = white_on_green + ab0 + normal if text[1] != "?": ab1 = white_on_green + ab1 + normal if text[2] != "?": ab2 = white_on_green + ab2 + normal if text[3] != "?": ab3 = white_on_green + ab3 + normal if text[4] != "?": ab4 = white_on_green + ab4 + normal colored_text = ab0 + ab1 + ab2 + ab3 + ab4 if color == "yellow": if text[0] != "*": ab0 = white_on_yellow + ab0 + normal if text[1] != "*": ab1 = white_on_yellow + ab1 + normal if text[2] != "*": ab2 = white_on_yellow + ab2 + normal if text[3] != "*": ab3 = white_on_yellow + ab3 + normal if text[4] != "*": ab4 = white_on_yellow + ab4 + normal colored_text = ab0 + ab1 + ab2 + ab3 + ab4 return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #7(2)

# 6432143021 sim = 82.95% import random import string def position_in_word(ch, word): if ch in word: if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 else: position = 4 return position else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = "" correct = "" new_puzzle_word = "" if puzzle_word[0] == guess_word[0]: new_guess_word += "-" correct += guess_word[0] new_puzzle_word += "-" else: new_guess_word += guess_word[0] correct += "?" new_puzzle_word += puzzle_word[0] if puzzle_word[1] == guess_word[1]: new_guess_word += "-" correct += guess_word[1] new_puzzle_word += "-" else: new_guess_word += guess_word[1] correct += "?" new_puzzle_word += puzzle_word[1] if puzzle_word[2] == guess_word[2]: new_guess_word += "-" correct += guess_word[2] new_puzzle_word += "-" else: new_guess_word += guess_word[2] correct += "?" new_puzzle_word += puzzle_word[2] if puzzle_word[3] == guess_word[3]: new_guess_word += "-" correct += guess_word[3] new_puzzle_word += "-" else: new_guess_word += guess_word[3] correct += "?" new_puzzle_word += puzzle_word[3] if puzzle_word[4] == guess_word[4]: new_guess_word += "-" correct += guess_word[4] new_puzzle_word += "-" else: new_guess_word += guess_word[4] correct += "?" new_puzzle_word += puzzle_word[4] return new_guess_word,correct,new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = "" if guess_word[0] in puzzle_word : wrong_position += guess_word[0] else: wrong_position += "*" if guess_word[1] in puzzle_word: wrong_position += guess_word[1] else: wrong_position += "*" if guess_word[2] in puzzle_word : wrong_position += guess_word[2] else: wrong_position += "*" if guess_word[3] in puzzle_word : wrong_position += guess_word[3] else: wrong_position += "*" if guess_word[4] in puzzle_word : wrong_position += guess_word[4] else: wrong_position += "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): ori_str = "" if k != 0: ori_str += (original_str[:k:]+ch+original_str[k+1::]) else: ori_str += (ch+original_str[k+1::]) return ori_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = "" if color == "green": if "A"<=text[0]<= "z": colored_text += (white_on_green+text[0]+normal) else: colored_text += (text[0]+normal) if "A"<=text[1]<= "z": colored_text += (white_on_green+text[1]+normal) else: colored_text += (text[1]+normal) if "A"<=text[2]<= "z": colored_text += (white_on_green+text[2]+normal) else: colored_text += (text[2]+normal) if "A"<=text[3]<= "z": colored_text += (white_on_green+text[3]+normal) else: colored_text += (text[3]+normal) if "A"<=text[4]<= "z": colored_text += (white_on_green+text[4]+normal) else: colored_text += (text[4]+normal) return colored_text elif color == "yellow": if "A"<=text[0]<= "Z": colored_text += (white_on_yellow+text[0]+normal) else: colored_text += (text[0]+normal) if "A"<=text[1]<= "Z": colored_text += (white_on_yellow+text[1]+normal) else: colored_text += (text[1]+normal) if "A"<=text[2]<= "Z": colored_text += (white_on_yellow+text[2]+normal) else: colored_text += (text[2]+normal) if "A"<=text[3]<= "Z": colored_text += (white_on_yellow+text[3]+normal) else: colored_text += (text[3]+normal) if "A"<=text[4]<= "Z": colored_text += (white_on_yellow+text[4]+normal) else: colored_text += (text[4]+normal) return colored_text else: return text# 6432145221 sim = 82.95% import random import string def position_in_word(ch, word): if not ch in word: position = -1 return position else: if ch in word[0]: position = 0 elif ch in word[1]: position = 1 elif ch in word[2]: position = 2 elif ch in word[3]: position = 3 else: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = "" correct = "" new_puzzle_word = "" if guess_word[0] == puzzle_word[0]: new_guess_word += '-' correct += guess_word[0] new_puzzle_word += '-' else: new_guess_word += guess_word[0] correct += '?' new_puzzle_word += puzzle_word[0] if guess_word[1] == puzzle_word[1]: new_guess_word += '-' correct += guess_word[1] new_puzzle_word += '-' else: new_guess_word += guess_word[1] correct += '?' new_puzzle_word += puzzle_word[1] if guess_word[2] == puzzle_word[2]: new_guess_word += '-' correct += guess_word[0] new_puzzle_word += '-' else: new_guess_word += guess_word[2] correct += '?' new_puzzle_word += puzzle_word[2] if guess_word[3] == puzzle_word[3]: new_guess_word += '-' correct += guess_word[3] new_puzzle_word += '-' else: new_guess_word += guess_word[3] correct += '?' new_puzzle_word += puzzle_word[3] if guess_word[4] == puzzle_word[4]: new_guess_word += '-' correct += guess_word[4] new_puzzle_word += '-' else: new_guess_word += guess_word[4] correct += '?' new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if not guess_word[0] == '-': if guess_word[0] in puzzle_word: wrong_position += guess_word[0] else: wrong_position += '*' else: pass if not guess_word[1] == '-': if guess_word[1] in puzzle_word: wrong_position += guess_word[1] else: wrong_position += '*' else: pass if not guess_word[2] == '-': if guess_word[2] in puzzle_word: wrong_position += guess_word[2] else: wrong_position += '*' else: pass if not guess_word[3] == '-': if guess_word[3] in puzzle_word: wrong_position += guess_word[3] else: wrong_position += '*' else: pass if not guess_word[4] == '-': if guess_word[4] in puzzle_word: wrong_position += guess_word[4] else: wrong_position += '*' else: pass return wrong_position def replace_kth_letter_in_str(original_str, k, ch): blank_str = "" if k != 0: blank_str += (original_str[:k:]+ch+original_str[k+1::]) else: blank_str += (ch+original_str[k+1::]) return blank_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = "" if color == "green": if "A"<=text[0]<= "z": colored_text += (white_on_green+text[0]+normal) else: colored_text += (text[0]+normal) if "A"<=text[1]<= "z": colored_text += (white_on_green+text[1]+normal) else: colored_text += (text[1]+normal) if "A"<=text[2]<= "z": colored_text += (white_on_green+text[2]+normal) else: colored_text += (text[2]+normal) if "A"<=text[3]<= "z": colored_text += (white_on_green+text[3]+normal) else: colored_text += (text[3]+normal) if "A"<=text[4]<= "z": colored_text += (white_on_green+text[4]+normal) else: colored_text += (text[4]+normal) return colored_text elif color == "yellow": if "A"<=text[0]<= "Z": colored_text += (white_on_yellow+text[0]+normal) else: colored_text += (text[0]+normal) if "A"<=text[1]<= "Z": colored_text += (white_on_yellow+text[1]+normal) else: colored_text += (text[1]+normal) if "A"<=text[2]<= "Z": colored_text += (white_on_yellow+text[2]+normal) else: colored_text += (text[2]+normal) if "A"<=text[3]<= "Z": colored_text += (white_on_yellow+text[3]+normal) else: colored_text += (text[3]+normal) if "A"<=text[4]<= "Z": colored_text += (white_on_yellow+text[4]+normal) else: colored_text += (text[4]+normal) return colored_text else: return text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #8(2)

# 6430345021 sim = 80.09% import random import string def position_in_word(ch, word): position = -1 for i in range(5): if word[i] == ch: position = i break return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word for i in range(5): if puzzle_word[i] == guess_word[i]: new_guess_word = replace_kth_letter_in_str(new_guess_word, i, "-") new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, i, "-") correct += puzzle_word[i] else: correct += "?" return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k + 1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' new_puzzle_word = puzzle_word for i in range(5): if position_in_word(guess_word[i], new_puzzle_word) != -1 and guess_word[i] != "-": wrong_position += guess_word[i] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, position_in_word(guess_word[i], new_puzzle_word), "-") else: wrong_position += "*" return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == "green": color_change = white_on_green else: color_change = '\033[34;43m' colored_text = '' for i in range(5): if text[i].isalpha(): colored_text += color_change + text[i] + normal else: colored_text += text[i] return colored_text# 6430450221 sim = 80.09% import random import string def position_in_word(ch, word): position = -1 for k in range(5): if word[k] == ch: position = k break return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word for k in range(5): if guess_word[k] == puzzle_word[k]: new_guess_word = replace_kth_letter_in_str(guess_word, k, '-') new_puzzle_word = replace_kth_letter_in_str(guess_word, k, '-') correct += guess_word[k] else: correct += '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k + 1:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' cnt = [0] * 26 for i in range(5): cnt[ord(puzzle_word[i]) - ord('A')] += 1 for i in range(5): if cnt[ord(guess_word[i]) - ord('A')] > 0: cnt[ord(guess_word[i]) - ord('A')] -= 1 wrong_position += guess_word[i] else: wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text if color == "green": color_change = white_on_green else: color_change = '\033[34;43m' for i in range(5): if text[i].isalpha(): colored_text += color_change + text[i] + normal else: colored_text += text[i] return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #9(2)

# 6430421021 sim = 76.04% import random import string def position_in_word(ch, word): if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): c = '-' new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0] : new_guess_word = replace_kth_letter_in_str(new_guess_word,0,c) correct = replace_kth_letter_in_str(correct,0,guess_word[0]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,0,c) if guess_word[1] == puzzle_word[1] : new_guess_word = replace_kth_letter_in_str(new_guess_word,1,c) correct = replace_kth_letter_in_str(correct,1,guess_word[1]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,1,c) if guess_word[2] == puzzle_word[2] : new_guess_word = replace_kth_letter_in_str(new_guess_word,2,c) correct = replace_kth_letter_in_str(correct,2,guess_word[2]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,2,c) if guess_word[3] == puzzle_word[3] : new_guess_word = replace_kth_letter_in_str(new_guess_word,3,c) correct = replace_kth_letter_in_str(correct,3,guess_word[3]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,3,c) if guess_word[4] == puzzle_word[4] : new_guess_word = replace_kth_letter_in_str(new_guess_word,4,c) correct = replace_kth_letter_in_str(correct,4,guess_word[4]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,4,c) return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): new_str = original_str[0:k:1] + ch + original_str[k+1::1] return new_str def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if (guess_word[0] in puzzle_word) and (guess_word[0] != puzzle_word[0]) and 'A' <= guess_word[0] <='Z' : wrong_position = replace_kth_letter_in_str(wrong_position, 0, guess_word[0]) puzzle_word = replace_letter(puzzle_word, guess_word[0], '*') if (guess_word[1] in puzzle_word) and (guess_word[1] != puzzle_word[1]) and 'A' <= guess_word[1] <='Z': wrong_position = replace_kth_letter_in_str(wrong_position, 1, guess_word[1]) puzzle_word = replace_letter(puzzle_word, guess_word[1], '*') if (guess_word[2] in puzzle_word) and (guess_word[2] != puzzle_word[2]) and 'A' <= guess_word[2] <='Z': wrong_position = replace_kth_letter_in_str(wrong_position, 2, guess_word[2]) puzzle_word = replace_letter(puzzle_word, guess_word[2], '*') if (guess_word[3] in puzzle_word) and (guess_word[3] != puzzle_word[3]) and 'A' <= guess_word[3] <='Z': wrong_position = replace_kth_letter_in_str(wrong_position, 3, guess_word[3]) puzzle_word = replace_letter(puzzle_word, guess_word[3], '*') if (guess_word[4] in puzzle_word) and (guess_word[4] != puzzle_word[4]) and 'A' <= guess_word[4] <='Z': wrong_position = replace_kth_letter_in_str(wrong_position, 4, guess_word[4]) puzzle_word = replace_letter(puzzle_word, guess_word[4], '*') return wrong_position def replace_letter(original, old_letter, new_letter): if old_letter in original: k = original.find(old_letter) original = original[:k] + new_letter + original[k+1:] return original def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = [text[0],text[1],text[2],text[3],text[4]] if color == 'green': h = white_on_green elif color == 'yellow': h = white_on_yellow if 'A' <= text[0] <='Z': colored_text[0] = h + text[0] + normal if 'A' <= text[1] <='Z': colored_text[1] = h + text[1] + normal if 'A' <= text[2] <='Z': colored_text[2] = h + text[2] + normal if 'A' <= text[3] <='Z': colored_text[3] = h + text[3] + normal if 'A' <= text[4] <='Z': colored_text[4] = h + text[4] + normal colored_text = ''.join(colored_text) return colored_text# 6432018221 sim = 76.04% import random import string def position_in_word(ch, word): if ch in word[0] : position = 0 elif ch in word[1] : position = 1 elif ch in word[2] : position = 2 elif ch in word[3] : position = 3 elif ch in word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if (puzzle_word[0] == guess_word[0]): new_guess_word = replace_kth_letter_in_str(new_guess_word, 0, '-') correct = replace_kth_letter_in_str(correct, 0, puzzle_word[0]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') if (puzzle_word[1] == guess_word[1]): new_guess_word = replace_kth_letter_in_str(new_guess_word, 1, '-') correct = replace_kth_letter_in_str(correct, 1, puzzle_word[1]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') if (puzzle_word[2] == guess_word[2]): new_guess_word = replace_kth_letter_in_str(new_guess_word, 2, '-') correct = replace_kth_letter_in_str(correct, 2, puzzle_word[2]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') if (puzzle_word[3] == guess_word[3]): new_guess_word = replace_kth_letter_in_str(new_guess_word, 3, '-') correct = replace_kth_letter_in_str(correct, 3, puzzle_word[3]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') if (puzzle_word[4] == guess_word[4]): new_guess_word = replace_kth_letter_in_str(new_guess_word, 4, '-') correct = replace_kth_letter_in_str(correct, 4, puzzle_word[4]) new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[0:k]+ ch + original_str[1+k:] def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if(guess_word[0] != '-' and position_in_word(guess_word[0], puzzle_word) != -1): wrong_position = replace_kth_letter_in_str(wrong_position, 0, guess_word[0]) puzzle_word = replace_letter(puzzle_word, guess_word[0], '-') if(guess_word[1] != '-' and position_in_word(guess_word[1], puzzle_word) != -1): wrong_position = replace_kth_letter_in_str(wrong_position, 1, guess_word[1]) puzzle_word = replace_letter(puzzle_word, guess_word[1], '-') if(guess_word[2] != '-' and position_in_word(guess_word[2], puzzle_word) != -1): wrong_position = replace_kth_letter_in_str(wrong_position, 2, guess_word[2]) puzzle_word = replace_letter(puzzle_word, guess_word[2], '-') if(guess_word[3] != '-' and position_in_word(guess_word[3], puzzle_word) != -1): wrong_position = replace_kth_letter_in_str(wrong_position, 3, guess_word[3]) puzzle_word = replace_letter(puzzle_word, guess_word[3], '-') if(guess_word[4] != '-' and position_in_word(guess_word[4], puzzle_word) != -1): wrong_position = replace_kth_letter_in_str(wrong_position, 4, guess_word[4]) puzzle_word = replace_letter(puzzle_word, guess_word[4], '-') return wrong_position def replace_letter(original, old_letter, new_letter): if old_letter in original: k = original.find(old_letter) original = original[:k] + new_letter + original[k+1:] return original def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text if color == 'green' : c = white_on_green else : c = white_on_yellow test = ['?', '*'] ch1 = text[0] ch2 = text[1] ch3 = text[2] ch4 = text[3] ch5 = text[4] if not(colored_text[0] in test): ch1 = c + colored_text[0] + normal if not(colored_text[1] in test) : ch2 = c + colored_text[1] + normal if not(colored_text[2] in test) : ch3 = c + colored_text[2] + normal if not(colored_text[3] in test) : ch4 = c + colored_text[3] + normal if not(colored_text[4] in test) : ch5 = c + colored_text[4] + normal return ch1 + ch2 + ch3 + ch4 + ch5

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #10(6)

# 6430419921 sim = 75.84% import random import string def position_in_word(ch, word): position = -1 for i in range(5) : if word[i] == ch : position =i return position def check_correct_position(puzzle_word, guess_word): new_guess_word = "" correct = "" new_puzzle_word = "" for i in range(5) : if guess_word[i] == puzzle_word[i] : new_guess_word += "-" correct += guess_word[i] new_puzzle_word += "-" else : new_guess_word += guess_word[i] correct += "?" new_puzzle_word += puzzle_word[i] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = "" for i in range(5) : if guess_word[i] in puzzle_word and (guess_word[i] != puzzle_word[i]) : wrong_position += guess_word[i] else : wrong_position += "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[0:k:] + ch +original_str[k+1::] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = "" for i in range(5) : if text[i] != "*" and text[i] != "?" : if color == "green" : colored_text += white_on_green + text[i] + normal if color == "yellow" : colored_text += white_on_yellow + text[i] + normal else : colored_text += text[i] return colored_text# 6432153221 sim = 75.84% import random import string def position_in_word(ch, word): position = -1 for i in range(len(word)): if ch == word[i]: position = i break return position def check_correct_position(puzzle_word, guess_word): new_guess_word = '' correct = '' new_puzzle_word = '' for i in range(len(puzzle_word)): if guess_word[i] == puzzle_word[i]: new_guess_word += '-' correct += guess_word[i] new_puzzle_word += '-' else: new_guess_word += guess_word[i] correct += '?' new_puzzle_word += puzzle_word[i] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' for i in range(len(puzzle_word)): if guess_word[i] in puzzle_word and guess_word[i].isalpha() == True: wrong_position += guess_word[i] puzzle_word = puzzle_word.replace(guess_word[i], '', 1) else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): new_str = '' for i in range(len(original_str)): if i == k: new_str += ch else: new_str += original_str[i] return new_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' for i in range(len(text)): if text[i].isalpha() == True: if color == 'green': colored_text += white_on_green + text[i] + normal elif color == 'yellow': colored_text += white_on_yellow + text[i] + normal else: colored_text += text[i] return colored_text# 6430244321 sim = 71.24% import random import string def position_in_word(ch, word): position = -1 for i in range(len(word)) : if word[i] == ch : position = i break return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word for i in range(5) : if puzzle_word[i] == guess_word[i] : new_puzzle_word = new_puzzle_word[:i] + '-' + new_puzzle_word[i+1:] correct += guess_word[i] new_guess_word = new_guess_word[:i] + '-' + new_guess_word[i+1:] else : new_puzzle_word = new_puzzle_word[:i] + puzzle_word[i] + new_puzzle_word[i+1:] correct += '?' new_guess_word = new_guess_word[:i] + guess_word[i] + new_guess_word[i+1:] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' puzzle_word_copy = puzzle_word[:] for x in guess_word : is_wrong = False for i in range(5) : if x== puzzle_word_copy[i] and x != '-' : puzzle_word_copy = puzzle_word_copy[:i] + '-' + puzzle_word_copy[i+1:] is_wrong = True break if is_wrong: wrong_position += x else : wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k+1:] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' char = "ABCDEFGHIGKLMNOPQRSTUVWXYZ" for i in range(len(text)) : if text[i] in char: if color == 'green' : colored_text += white_on_green elif color == 'yellow' : colored_text += white_on_yellow colored_text += text[i] + normal else : colored_text += text[i] return colored_text# 6130270821 sim = 71.12% import random import string def position_in_word(ch, word): for i in range(len(word)): if word[i] == ch: return i return -1 def check_correct_position(puzzle_word, guess_word): correct = '' new_puzzle_word = '' for i in range(len(puzzle_word)): if puzzle_word[i] == guess_word[i]: correct += puzzle_word[i] new_puzzle_word += '-' else: correct += '?' new_puzzle_word += puzzle_word[i] return correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' for i in range(len(puzzle_word)): if guess_word[i] in puzzle_word: if wrong_position.count(guess_word[i]) < puzzle_word.count(guess_word[i]): wrong_position += guess_word[i] else: wrong_position += '*' else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + '-' + original_str[k + 1:] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' for i in text: if i.isalpha(): if color == 'green': colored_text += white_on_green elif color == 'yellow': colored_text += white_on_yellow colored_text += i + normal else: colored_text += i return colored_text# 6430370721 sim = 70.96% import random import string def position_in_word(ch, word): try : return word.index(ch) except : return -1 def check_correct_position(puzzle_word, guess_word): new_guess_word = str() correct = str() new_puzzle_word = str() for i in range(5) : if puzzle_word[i] == guess_word[i] : new_guess_word += '-' correct += puzzle_word[i] new_puzzle_word += '-' else : new_guess_word += guess_word[i] correct += '?' new_puzzle_word += puzzle_word[i] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = str() puzzle_word = list(puzzle_word) guess_word = list(guess_word) for ch in guess_word : if ch in puzzle_word and ch.isalpha() : puzzle_word.remove(ch) wrong_position += ch else : wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[k+1:] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = str() for ch in text : if ch.isalpha() : if color == 'green' : colored_text += white_on_green + ch + normal if color == 'yellow' : colored_text += white_on_yellow + ch + normal else : colored_text += ch return colored_text# 6430263221 sim = 70.01% import random import string def position_in_word(ch, word): a = 0 if ch in word : while ch != word[a] : a +=1 position = a else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = '' correct = '' new_puzzle_word = '' for i in range(5): if puzzle_word[i] == guess_word[i]: new_guess_word += '-' correct += guess_word[i] new_puzzle_word += '-' else: new_guess_word += guess_word[i] correct += '?' new_puzzle_word += puzzle_word[i] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' char = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' a = [str(i) for i in puzzle_word] for i in range(5): if guess_word[i] in char : if guess_word[i] in a: wrong_position += guess_word[i] a.remove(guess_word[i]) else : wrong_position += '*' else : wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): a = [i for i in original_str] a[k] = ch a = ''.join(str(i) for i in a) return a def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' char = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' colored_text = '' for i in range(5): if text[i] in char : if color == 'green' : colored_text += (white_on_green + text[i] + normal) elif color == 'yellow' : colored_text += (white_on_yellow + text[i] + normal) else : colored_text += text[i] else : colored_text += text[i] return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #11(2)

# 6230027321 sim = 75.76% import random import string def position_in_word(ch, word): position = -1 if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = list(guess_word) correct = list("?????") new_puzzle_word = list(puzzle_word) if guess_word[0] == puzzle_word[0] : new_guess_word[0] = "-" correct[0] = puzzle_word[0] new_puzzle_word[0] = "-" if guess_word[1] == puzzle_word[1] : new_guess_word[1] = "-" correct[1] = puzzle_word[1] new_puzzle_word[1] = "-" if guess_word[2] == puzzle_word[2] : new_guess_word[2] = "-" correct[2] = puzzle_word[2] new_puzzle_word[2] = "-" if guess_word[3] == puzzle_word[3] : new_guess_word[3] = "-" correct[3] = puzzle_word[3] new_puzzle_word[3] = "-" if guess_word[4] == puzzle_word[4] : new_guess_word[4] = "-" correct[4] = puzzle_word[4] new_puzzle_word[4] = "-" return "".join(new_guess_word), "".join(correct), "".join(new_puzzle_word) def check_wrong_position(puzzle_word, guess_word): wrong_position = list("*****") if puzzle_word[0] != guess_word[0] and guess_word[0] in puzzle_word : wrong_position[0] = guess_word[0] if puzzle_word[1] != guess_word[1] and guess_word[1] in puzzle_word : wrong_position[1] = guess_word[1] if puzzle_word[2] != guess_word[2] and guess_word[2] in puzzle_word : wrong_position[2] = guess_word[2] if puzzle_word[3] != guess_word[3] and guess_word[3] in puzzle_word : wrong_position[3] = guess_word[3] if puzzle_word[4] != guess_word[4] and guess_word[4] in puzzle_word : wrong_position[4] = guess_word[4] return "".join(wrong_position) def replace_kth_letter_in_str(original_str, k, ch): x = list(original_str) x[k] = ch return "".join(x) def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = list(text) if color == "green" : c = white_on_green elif color == "yellow" : c = white_on_yellow if "A" <= text[0] <= "Z" : colored_text[0] = c + text[0] + normal if "A" <= text[1] <= "Z" : colored_text[1] = c + text[1] + normal if "A" <= text[2] <= "Z" : colored_text[2] = c + text[2] + normal if "A" <= text[3] <= "Z" : colored_text[3] = c + text[3] + normal if "A" <= text[4] <= "Z" : colored_text[4] = c + text[4] + normal return "".join(colored_text)# 6432141721 sim = 75.76% import random import string def position_in_word(ch, word): if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = list(guess_word) correct_word = ["?"]*5 new_puzzle_word = list(puzzle_word) if guess_word[0] == puzzle_word[0]: new_guess_word[0] = '-' correct_word[0] = puzzle_word[0] new_puzzle_word[0] = '-' if guess_word[1] == puzzle_word[1]: new_guess_word[1] = '-' correct_word[1] = puzzle_word[1] new_puzzle_word[1] = '-' if guess_word[2] == puzzle_word[2]: new_guess_word[2] = '-' correct_word[2] = puzzle_word[2] new_puzzle_word[2] = '-' if guess_word[3] == puzzle_word[3]: new_guess_word[3] = '-' correct_word[3] = puzzle_word[3] new_puzzle_word[3] = '-' if guess_word[4] == puzzle_word[4]: new_guess_word[4] = '-' correct_word[4] = puzzle_word[4] new_puzzle_word[4] = '-' new_guess_word = ''.join(new_guess_word) correct_word = ''.join(correct_word) new_puzzle_word = ''.join(new_puzzle_word) return new_guess_word,correct_word, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = ["*"] * 5 use_puzzle_word = list(puzzle_word) if puzzle_word[0] != guess_word[0] and guess_word[0] in use_puzzle_word: wrong_position[0] = guess_word[0] use_puzzle_word[position_in_word(guess_word[0], use_puzzle_word)] = "$" if puzzle_word[1] != guess_word[1] and guess_word[1] in use_puzzle_word: wrong_position[1] = guess_word[1] use_puzzle_word[position_in_word(guess_word[1], use_puzzle_word)] = "$" if puzzle_word[2] != guess_word[2] and guess_word[2] in use_puzzle_word: wrong_position[2] = guess_word[2] use_puzzle_word[position_in_word(guess_word[2], use_puzzle_word)] = "$" if puzzle_word[3] != guess_word[3] and guess_word[3] in use_puzzle_word: wrong_position[3] = guess_word[3] use_puzzle_word[position_in_word(guess_word[3], use_puzzle_word)] = "$" if puzzle_word[4] != guess_word[4] and guess_word[4] in use_puzzle_word: wrong_position[4] = guess_word[4] use_puzzle_word[position_in_word(guess_word[4], use_puzzle_word)] = "$" return ''.join(wrong_position) def replace_kth_letter_in_str(original_str, k, ch): original_str = list(original_str) original_str[k] = ch original_str = ''.join(original_str) return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = list(text) if color == 'green': choosen_color = white_on_green elif color == 'yellow': choosen_color = white_on_yellow if 'A' <= text[0] <= 'Z': colored_text[0] = choosen_color + text[0] + normal if 'A' <= text[1] <= 'Z': colored_text[1] = choosen_color + text[1] + normal if 'A' <= text[2] <= 'Z': colored_text[2] = choosen_color + text[2] + normal if 'A' <= text[3] <= 'Z': colored_text[3] = choosen_color + text[3] + normal if 'A' <= text[4] <= 'Z': colored_text[4] = choosen_color + text[4] + normal return ''.join(colored_text)

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #12(2)

# 6430434221 sim = 75.35% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '' new_puzzle_word = puzzle_word new_guess_word = '' if puzzle_word[0] == guess_word[0]: correct += puzzle_word[0] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') new_guess_word += '-' else: correct += '?' new_guess_word += guess_word[0] if puzzle_word[1] == guess_word[1]: correct += puzzle_word[1] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') new_guess_word += '-' else: correct += '?' new_guess_word += guess_word[1] if puzzle_word[2] == guess_word[2]: correct += puzzle_word[2] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') new_guess_word += '-' else: correct += '?' new_guess_word += guess_word[2] if puzzle_word[3] == guess_word[3]: correct += puzzle_word[3] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') new_guess_word += '-' else: correct += '?' new_guess_word += guess_word[3] if puzzle_word[4] == guess_word[4]: correct += puzzle_word[4] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') new_guess_word += '-' else: correct += '?' new_guess_word += guess_word[4] return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): replace_original = original_str[:k:] + ch + original_str[k + 1::] return replace_original def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] == puzzle_word[1] and guess_word[0] != '-': wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') elif guess_word[0] == puzzle_word[2] and guess_word[0] != '-': wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') elif guess_word[0] == puzzle_word[3] and guess_word[0] != '-': wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') elif guess_word[0] == puzzle_word[4] and guess_word[0] != '-': wrong_position += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') else: wrong_position += '*' if guess_word[1] == puzzle_word[0] and guess_word[1] != '-': wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') elif guess_word[1] == puzzle_word[2] and guess_word[1] != '-': wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') elif guess_word[1] == puzzle_word[3] and guess_word[1] != '-': wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') elif guess_word[1] == puzzle_word[4] and guess_word[1] != '-': wrong_position += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') else: wrong_position += '*' if guess_word[2] == puzzle_word[0] and guess_word[2] != '-': wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') elif guess_word[2] == puzzle_word[1] and guess_word[2] != '-': wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') elif guess_word[2] == puzzle_word[3] and guess_word[2] != '-': wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') elif guess_word[2] == puzzle_word[4] and guess_word[2] != '-': wrong_position += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') else: wrong_position += '*' if guess_word[3] == puzzle_word[0] and guess_word[3] != '-': wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') elif guess_word[3] == puzzle_word[1] and guess_word[3] != '-': wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') elif guess_word[3] == puzzle_word[2] and guess_word[3] != '-': wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') elif guess_word[3] == puzzle_word[4] and guess_word[3] != '-': wrong_position += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') else: wrong_position += '*' if guess_word[4] == puzzle_word[0] and guess_word[4] != '-': wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') elif guess_word[4] == puzzle_word[1] and guess_word[4] != '-': wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') elif guess_word[4] == puzzle_word[2] and guess_word[4] != '-': wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') elif guess_word[4] == puzzle_word[3] and guess_word[4] != '-': wrong_position += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') else: wrong_position += '*' return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if text[0] != '?' and text[0] != '*': if color == 'green': colored_text += white_on_green + text[0] + normal elif color == 'yellow': colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if text[1] != '?' and text[1] != '*': if color == 'green': colored_text += white_on_green + text[1] + normal elif color == 'yellow': colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if text[2] != '?' and text[2] != '*': if color == 'green': colored_text += white_on_green + text[2] + normal elif color == 'yellow': colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if text[3] != '?' and text[3] != '*': if color == 'green': colored_text += white_on_green + text[3] + normal elif color == 'yellow': colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if text[4] != '?' and text[4] != '*': if color == 'green': colored_text += white_on_green + text[4] + normal elif color == 'yellow': colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text# 6430444521 sim = 75.35% import random import string def position_in_word(ch, word): position = -1 if ch in word[0]: position = 0 elif ch in word[1]: position = 1 elif ch in word[2]: position = 2 elif ch in word[3]: position = 3 elif ch in word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if new_guess_word[0] == new_puzzle_word[0]: correct += new_guess_word[0] new_guess_word = replace_letter(new_guess_word ,new_guess_word[0] ,"-") new_puzzle_word = replace_letter(new_puzzle_word ,new_puzzle_word[0] ,"-") else: correct += "?" if new_guess_word[1] == new_puzzle_word[1]: correct += new_guess_word[1] new_guess_word = replace_letter(new_guess_word ,new_guess_word[1] ,"-") new_puzzle_word = replace_letter(new_puzzle_word ,new_puzzle_word[1] ,"-") else: correct += "?" if new_guess_word[2] == new_puzzle_word[2]: correct += new_guess_word[2] new_guess_word = replace_letter(new_guess_word ,new_guess_word[2] ,"-") new_puzzle_word = replace_letter(new_puzzle_word ,new_puzzle_word[2] ,"-") else: correct += "?" if new_guess_word[3] == new_puzzle_word[3]: correct += new_guess_word[3] new_guess_word = replace_letter(new_guess_word ,new_guess_word[3] ,"-") new_puzzle_word = replace_letter(new_puzzle_word ,new_puzzle_word[3] ,"-") else: correct += "?" if new_guess_word[4] == new_puzzle_word[4]: correct += new_guess_word[4] new_guess_word = replace_letter(new_guess_word ,new_guess_word[4] ,"-") new_puzzle_word = replace_letter(new_puzzle_word ,new_puzzle_word[4] ,"-") else: correct += "?" return new_guess_word, correct, new_puzzle_word def replace_letter(original, old_letter, new_letter): if old_letter in original: k = original.find(old_letter) original = original[:k] + new_letter + original[k+1:] return original def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0]==puzzle_word[1] and guess_word[0]!="-": wrong_position+=guess_word[0] puzzle_word=replace_kth_letter_in_str(puzzle_word, 1, "-") elif guess_word[0]==puzzle_word[2] and guess_word[0]!="-": wrong_position+=guess_word[0] puzzle_word=replace_kth_letter_in_str(puzzle_word, 2, "-") elif guess_word[0]==puzzle_word[3] and guess_word[0]!="-": wrong_position+=guess_word[0] puzzle_word=replace_kth_letter_in_str(puzzle_word, 3, "-") elif guess_word[0]==puzzle_word[4] and guess_word[0]!="-": wrong_position+=guess_word[0] puzzle_word=replace_kth_letter_in_str(puzzle_word, 4, "-") else: wrong_position+="*" if guess_word[1]==puzzle_word[0] and guess_word[1]!="-": wrong_position+=guess_word[1] puzzle_word=replace_kth_letter_in_str(puzzle_word, 0, "-") elif guess_word[1]==puzzle_word[2] and guess_word[1]!="-": wrong_position+=guess_word[1] puzzle_word=replace_kth_letter_in_str(puzzle_word, 2, "-") elif guess_word[1]==puzzle_word[3] and guess_word[1]!="-": wrong_position+=guess_word[1] puzzle_word=replace_kth_letter_in_str(puzzle_word, 3, "-") elif guess_word[1]==puzzle_word[4] and guess_word[1]!="-": wrong_position+=guess_word[1] puzzle_word=replace_kth_letter_in_str(puzzle_word, 4, "-") else: wrong_position+="*" if guess_word[2]==puzzle_word[0] and guess_word[2]!="-": wrong_position+=guess_word[2] puzzle_word=replace_kth_letter_in_str(puzzle_word, 0, "-") elif guess_word[2]==puzzle_word[1] and guess_word[2]!="-": wrong_position+=guess_word[2] puzzle_word=replace_kth_letter_in_str(puzzle_word, 1, "-") elif guess_word[2]==puzzle_word[3] and guess_word[2]!="-": wrong_position+=guess_word[2] puzzle_word=replace_kth_letter_in_str(puzzle_word, 3, "-") elif guess_word[2]==puzzle_word[4] and guess_word[2]!="-": wrong_position+=guess_word[2] puzzle_word=replace_kth_letter_in_str(puzzle_word, 4, "-") else: wrong_position+="*" if guess_word[3]==puzzle_word[0] and guess_word[3]!="-": wrong_position+=guess_word[3] puzzle_word=replace_kth_letter_in_str(puzzle_word, 0, "-") elif guess_word[3]==puzzle_word[1] and guess_word[3]!="-": wrong_position+=guess_word[3] puzzle_word=replace_kth_letter_in_str(puzzle_word, 1, "-") elif guess_word[3]==puzzle_word[2] and guess_word[3]!="-": wrong_position+=guess_word[3] puzzle_word=replace_kth_letter_in_str(puzzle_word, 2, "-") elif guess_word[3]==puzzle_word[4] and guess_word[3]!="-": wrong_position+=guess_word[3] puzzle_word=replace_kth_letter_in_str(puzzle_word, 4, "-") else: wrong_position+="*" if guess_word[4]==puzzle_word[0] and guess_word[4]!="-": wrong_position+=guess_word[4] puzzle_word=replace_kth_letter_in_str(puzzle_word, 0, "-") elif guess_word[4]==puzzle_word[1] and guess_word[4]!="-": wrong_position+=guess_word[4] puzzle_word=replace_kth_letter_in_str(puzzle_word, 1, "-") elif guess_word[4]==puzzle_word[2] and guess_word[4]!="-": wrong_position+=guess_word[4] puzzle_word=replace_kth_letter_in_str(puzzle_word, 2, "-") elif guess_word[4]==puzzle_word[3] and guess_word[4]!="-": wrong_position+=guess_word[4] puzzle_word=replace_kth_letter_in_str(puzzle_word, 3, "-") else: wrong_position+="*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): original_str = original_str[:k] + ch + original_str[k+1:] return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = "" if color == "green" : if text[0] != "?" and text[0] != "*": colored_text += white_on_green + text[0] + normal else: colored_text += text[0] if text[1] != "?" and text[1] != "*": colored_text += white_on_green + text[1] + normal else: colored_text += text[1] if text[2] != "?" and text[2] != "*": colored_text += white_on_green + text[2] + normal else: colored_text += text[2] if text[3] != "?" and text[3] != "*": colored_text += white_on_green + text[3] + normal else: colored_text += text[3] if text[4] != "?" and text[4] != "*": colored_text += white_on_green + text[4] + normal else: colored_text += text[4] elif color == "yellow": if text[0] != "?" and text[0] != "*": colored_text += white_on_yellow + text[0] + normal else: colored_text += text[0] if text[1] != "?" and text[1] != "*": colored_text += white_on_yellow + text[1] + normal else: colored_text += text[1] if text[2] != "?" and text[2] != "*": colored_text += white_on_yellow + text[2] + normal else: colored_text += text[2] if text[3] != "?" and text[3] != "*": colored_text += white_on_yellow + text[3] + normal else: colored_text += text[3] if text[4] != "?" and text[4] != "*": colored_text += white_on_yellow + text[4] + normal else: colored_text += text[4] return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #13(2)

# 6430200721 sim = 74.69% import random import string def position_in_word(ch, word): if ch in word[0]: position = 0 elif ch in word[1]: position = 1 elif ch in word[2]: position = 2 elif ch in word[3]: position = 3 elif ch in word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = "" correct = "" new_puzzle_word = "" if puzzle_word[0] == guess_word[0]: new_guess_word += "-" correct += puzzle_word[0] new_puzzle_word += "-" else: new_guess_word += guess_word[0] correct += "?" new_puzzle_word += puzzle_word[0] if puzzle_word[1] == guess_word[1]: new_guess_word += "-" correct += puzzle_word[1] new_puzzle_word += "-" else: new_guess_word += guess_word[1] correct += "?" new_puzzle_word += puzzle_word[1] if puzzle_word[2] == guess_word[2]: new_guess_word += "-" correct += puzzle_word[2] new_puzzle_word += "-" else: new_guess_word += guess_word[2] correct += "?" new_puzzle_word += puzzle_word[2] if puzzle_word[3] == guess_word[3]: new_guess_word += "-" correct += puzzle_word[3] new_puzzle_word += "-" else: new_guess_word += guess_word[3] correct += "?" new_puzzle_word += puzzle_word[3] if puzzle_word[4] == guess_word[4]: new_guess_word += "-" correct += puzzle_word[4] new_puzzle_word += "-" else: new_guess_word += guess_word[4] correct += "?" new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' pw = puzzle_word gw = guess_word nm = [0, 0, 0, 0, 0] if gw[0] != "-": if gw[0] == pw[0] and nm[0] == 0: wrong_position += gw[0] nm[0] += 1 elif gw[0] == pw[1] and nm[1] == 0: wrong_position += gw[0] nm[1] += 1 elif gw[0] == pw[2] and nm[2] == 0: wrong_position += gw[0] nm[2] += 1 elif gw[0] == pw[3] and nm[3] == 0: wrong_position += gw[0] nm[3] += 1 elif gw[0] == pw[4] and nm[4] == 0: wrong_position += gw[0] nm[4] += 1 else: wrong_position += "*" else: wrong_position += "*" if gw[1] != "-": if gw[1] == pw[0] and nm[0] == 0: wrong_position += gw[1] nm[0] += 1 elif gw[1] == pw[1] and nm[1] == 0: wrong_position += gw[1] nm[1] += 1 elif gw[1] == pw[2] and nm[2] == 0: wrong_position += gw[1] nm[2] += 1 elif gw[1] == pw[3] and nm[3] == 0: wrong_position += gw[1] nm[3] += 1 elif gw[1] == pw[4] and nm[4] == 0: wrong_position += gw[1] nm[4] += 1 else: wrong_position += "*" else: wrong_position += "*" if gw[1] != "-": if gw[2] == pw[0] and nm[0] == 0: wrong_position += gw[2] nm[0] += 1 elif gw[2] == pw[1] and nm[1] == 0: wrong_position += gw[2] nm[1] += 1 elif gw[2] == pw[2] and nm[2] == 0: wrong_position += gw[2] nm[2] += 1 elif gw[2] == pw[3] and nm[3] == 0: wrong_position += gw[2] nm[3] += 1 elif gw[2] == pw[4] and nm[4] == 0: wrong_position += gw[2] nm[4] += 1 else: wrong_position += "*" else: wrong_position += "*" if gw[3] != "-": if gw[3] == pw[0] and nm[0] == 0: wrong_position += gw[3] nm[0] += 1 elif gw[3] == pw[1] and nm[1] == 0: wrong_position += gw[3] nm[1] += 1 elif gw[3] == pw[2] and nm[2] == 0: wrong_position += gw[3] nm[2] += 1 elif gw[3] == pw[3] and nm[3] == 0: wrong_position += gw[3] nm[3] += 1 elif gw[3] == pw[4] and nm[4] == 0: wrong_position += gw[3] nm[4] += 1 else: wrong_position += "*" else: wrong_position += "*" if gw[4] != "-": if gw[4] == pw[0] and nm[0] == 0: wrong_position += gw[4] nm[0] += 1 elif gw[4] == pw[1] and nm[1] == 0: wrong_position += gw[4] nm[1] += 1 elif gw[4] == pw[2] and nm[2] == 0: wrong_position += gw[4] nm[2] += 1 elif gw[4] == pw[3] and nm[3] == 0: wrong_position += gw[4] nm[3] += 1 elif gw[4] == pw[4] and nm[4] == 0: wrong_position += gw[4] nm[4] += 1 else: wrong_position += "*" else: wrong_position += "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): a = "" if k == 0: a += ch a += original_str[1:5] elif k == 1: a += original_str[0] a += ch a += original_str[2:5] elif k == 2: a += original_str[0:2] a += ch a += original_str[3:5] elif k == 3: a += original_str[0:3] a += ch a += original_str[4:5] elif k == 4: a += original_str[0:4] a += ch return a def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' al = '' if "A" <= text[0] <= "Z": if color == 'green': j0 = white_on_green + text[0] + normal al += j0 if color == 'yellow': j0 = white_on_yellow + text[0] + normal al += j0 else: al += text[0] if "A" <= text[1] <= "Z": if color == 'green': j1 = white_on_green + text[1] + normal al += j1 if color == 'yellow': j1 = white_on_yellow + text[1] + normal al += j1 else: al += text[1] if "A" <= text[2] <= "Z": if color == 'green': j2 = white_on_green + text[2] + normal al += j2 if color == 'yellow': j2 = white_on_yellow + text[2] + normal al += j2 else: al += text[2] if "A" <= text[3] <= "Z": if color == 'green': j3 = white_on_green + text[3] + normal al += j3 if color == 'yellow': j3 = white_on_yellow + text[3] + normal al += j3 else: al += text[3] if "A" <= text[4] <= "Z": if color == 'green': j4 = white_on_green + text[4] + normal al += j4 if color == 'yellow': j4 = white_on_yellow + text[4] + normal al += j4 else: al += text[4] colored_text = al return colored_text# 6430259821 sim = 74.69% import random import string def position_in_word(ch, word): if len(ch)==1 and len(word)==5: if ch == word[0]: position=0 if ch == word[1]: position=1 if ch == word[2]: position=2 if ch == word[3]: position=3 if ch == word[4]: position=4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = '' correct = '' new_puzzle_word ='' if guess_word[0]== puzzle_word[0] : new_guess_word += '-' correct +=puzzle_word[0] new_puzzle_word += '-' else: new_guess_word +=guess_word[0] correct +='?' new_puzzle_word += puzzle_word[0] if guess_word[1]== puzzle_word[1] : new_guess_word += '-' correct +=puzzle_word[1] new_puzzle_word += '-' else: new_guess_word +=guess_word[1] correct +='?' new_puzzle_word += puzzle_word[1] if guess_word[2]== puzzle_word[2] : new_guess_word += '-' correct +=puzzle_word[2] new_puzzle_word += '-' else: new_guess_word +=guess_word[2] correct +='?' new_puzzle_word += puzzle_word[2] if guess_word[3]== puzzle_word[3] : new_guess_word += '-' correct +=puzzle_word[3] new_puzzle_word += '-' else: new_guess_word +=guess_word[3] correct +='?' new_puzzle_word += puzzle_word[3] if guess_word[4]== puzzle_word[4] : new_guess_word += '-' correct +=puzzle_word[4] new_puzzle_word += '-' else: new_guess_word +=guess_word[4] correct +='?' new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' g=[1,1,1,1,1] if guess_word[0]== puzzle_word[0] and g[0]==1 and guess_word[0] != '-': wrong_position = guess_word[0] g[0] -=1 elif guess_word[0]== puzzle_word[1] and g[2]==1 and guess_word[0] != '-': wrong_position = guess_word[0] g[1] -=1 elif guess_word[0]== puzzle_word[2] and g[2]==1 and guess_word[0] != '-': wrong_position = guess_word[0] g[2] -=1 elif guess_word[0]== puzzle_word[3] and g[3]==1 and guess_word[0] != '-': wrong_position = guess_word[0] g[3] -=1 elif guess_word[0]== puzzle_word[4] and g[4]==1 and guess_word[0] != '-': wrong_position = guess_word[0] g[4] -=1 else: wrong_position += '*' if guess_word[1]== puzzle_word[0] and g[0]==1 and guess_word[1] != '-': wrong_position += guess_word[1] g[0] -=1 elif guess_word[1]== puzzle_word[1] and g[1]==1 and guess_word[1] != '-': wrong_position += guess_word[1] g[1] -=1 elif guess_word[1]== puzzle_word[2] and g[2]==1 and guess_word[1] != '-': wrong_position += guess_word[1] g[2] -=1 elif guess_word[1]== puzzle_word[3] and g[3]==1 and guess_word[1] != '-': wrong_position += guess_word[1] g[3] -=1 elif guess_word[1]== puzzle_word[4] and g[4]==1 and guess_word[1] != '-': wrong_position += guess_word[1] g[4] -=1 else: wrong_position += '*' if guess_word[2]== puzzle_word[0] and g[0]==1 and guess_word[2] != '-': wrong_position += guess_word[2] g[0] -=1 elif guess_word[2]== puzzle_word[1] and g[1]==1 and guess_word[2] != '-': wrong_position += guess_word[2] g[1] -=1 elif guess_word[2]== puzzle_word[2] and g[2]==1 and guess_word[2] != '-': wrong_position += guess_word[2] g[2] -=1 elif guess_word[2]== puzzle_word[3] and g[3]==1 and guess_word[2] != '-': wrong_position += guess_word[2] g[3] -=1 elif guess_word[2]== puzzle_word[4] and g[4]==1 and guess_word[2] != '-': wrong_position += guess_word[2] g[4] -=1 else: wrong_position += '*' if guess_word[3]== puzzle_word[0] and g[0]==1 and guess_word[3] != '-': wrong_position += guess_word[3] g[0] -=1 elif guess_word[3]== puzzle_word[1] and g[1]==1 and guess_word[3] != '-': wrong_position += guess_word[3] g[1] -=1 elif guess_word[3]== puzzle_word[2] and g[2]==1 and guess_word[3] != '-': wrong_position += guess_word[3] g[2] -=1 elif guess_word[3]== puzzle_word[3] and g[3]==1 and guess_word[3] != '-': wrong_position += guess_word[3] g[3] -=1 elif guess_word[3]== puzzle_word[4] and g[4]==1 and guess_word[3] != '-': wrong_position += guess_word[3] g[4] -=1 else: wrong_position += '*' if guess_word[4]== puzzle_word[0] and g[0]==1 and guess_word[4] != '-': wrong_position += guess_word[4] g[0] -=1 elif guess_word[4]== puzzle_word[1] and g[1]==1 and guess_word[4] != '-': wrong_position += guess_word[4] g[1] -=1 elif guess_word[4]== puzzle_word[2] and g[2]==1 and guess_word[4] != '-': wrong_position += guess_word[4] g[2] -=1 elif guess_word[4]== puzzle_word[3] and g[3]==1 and guess_word[4] != '-': wrong_position += guess_word[4] g[3] -=1 elif guess_word[4]== puzzle_word[4] and g[4]==1 and guess_word[4] != '-': wrong_position += guess_word[4] g[4] -=1 else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): b='' if k==0 : b= ch + original_str[1:] elif k==1 : b= original_str[0:1] + ch + original_str[2:] elif k==2 : b= original_str[0:2] + ch + original_str[3:] elif k==3 : b= original_str[0:3] + ch + original_str[4:] elif k==4: b= original_str[0:4] + ch return b def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' a='' if 'A'<= text[0] <='Z': if color== 'green': a += white_on_green + text[0] + normal if color=='yellow': a += white_on_yellow + text[0] + normal else: a += text[0] if 'A'<= text[1] <='Z': if color=='green': a += white_on_green + text[1] + normal if color=='yellow': a += white_on_yellow + text[1] + normal else: a += text[1] if 'A'<= text[2] <='Z': if color=='green': a += white_on_green + text[2] + normal if color=='yellow': a += white_on_yellow + text[2] + normal else: a += text[2] if 'A'<= text[3] <='Z': if color=='green': a += white_on_green + text[3] + normal if color=='yellow': a += white_on_yellow + text[3] + normal else: a += text[3] if 'A'<= text[4] <='Z': if color=='green': a += white_on_green + text[4] + normal if color=='yellow': a += white_on_yellow + text[4] + normal else: a += text[4] colored_text=a return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #14(2)

# 6430314621 sim = 74.27% import random import string def position_in_word(ch, word): position = -1 if word[0]==ch: position=0 elif word[1]==ch: position=1 elif word[2]==ch: position=2 elif word[3]==ch: position=3 elif word[4]==ch: position=4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if puzzle_word[0]==guess_word[0]: new_guess_word=new_guess_word[:0]+'-'+new_guess_word[0 + 1:] correct=correct[:0]+puzzle_word[0]+correct[0 + 1:] new_puzzle_word=new_puzzle_word[:0]+'-'+new_puzzle_word[0 + 1:] if puzzle_word[1]==guess_word[1]: new_guess_word=new_guess_word[:1]+'-'+new_guess_word[1 + 1:] correct=correct[:1]+puzzle_word[1]+correct[1 + 1:] new_puzzle_word=new_puzzle_word[:1]+'-'+new_puzzle_word[1 + 1:] if puzzle_word[2]==guess_word[2]: new_guess_word=new_guess_word[:2]+'-'+new_guess_word[2 + 1:] correct=correct[:2]+puzzle_word[2]+correct[2 + 1:] new_puzzle_word=new_puzzle_word[:2]+'-'+new_puzzle_word[2 + 1:] if puzzle_word[3]==guess_word[3]: new_guess_word=new_guess_word[:3]+'-'+new_guess_word[3 + 1:] correct=correct[:3]+puzzle_word[3]+correct[3 + 1:] new_puzzle_word=new_puzzle_word[:3]+'-'+new_puzzle_word[3 + 1:] if puzzle_word[4]==guess_word[4]: new_guess_word=new_guess_word[:4]+'-'+new_guess_word[4 + 1:] correct=correct[:4]+puzzle_word[4]+correct[4 + 1:] new_puzzle_word=new_puzzle_word[:4]+'-'+new_puzzle_word[4 + 1:] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' NPW = puzzle_word if guess_word[0] in NPW and guess_word[0] != puzzle_word[0]: wrong_position += guess_word[0] NPW = replace_kth_letter_in_str(NPW, position_in_word(guess_word[0], NPW), '不') else: wrong_position += '*' if guess_word[1] in NPW and guess_word[1] != puzzle_word[1]: wrong_position += guess_word[1] NPW = replace_kth_letter_in_str(NPW, position_in_word(guess_word[1], NPW), '不') else: wrong_position += '*' if guess_word[2] in NPW and guess_word[2] != puzzle_word[2]: wrong_position += guess_word[2] NPW = replace_kth_letter_in_str(NPW, position_in_word(guess_word[2], NPW), '不') else: wrong_position += '*' if guess_word[3] in NPW and guess_word[3] != puzzle_word[3]: wrong_position += guess_word[3] NPW = replace_kth_letter_in_str(NPW, position_in_word(guess_word[3], NPW), '不') else: wrong_position += '*' if guess_word[4] in NPW and guess_word[4] != puzzle_word[4]: wrong_position += guess_word[4] NPW = replace_kth_letter_in_str(NPW, position_in_word(guess_word[4], NPW), '不') else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k]+ch+original_str[k+1:] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green': if 'A' <= text[0] <= 'Z': colored_text += white_on_green + text[0] else:colored_text += normal + text[0] if 'A' <= text[1] <= 'Z': colored_text += white_on_green + text[1] else:colored_text += normal + text[1] if 'A' <= text[2] <= 'Z': colored_text += white_on_green + text[2] else:colored_text += normal + text[2] if 'A' <= text[3] <= 'Z': colored_text += white_on_green + text[3] else:colored_text += normal + text[3] if 'A' <= text[4] <= 'Z': colored_text += white_on_green + text[4] + normal else:colored_text += normal + text[4] if color == 'yellow': if 'A' <= text[0] <= 'Z': colored_text += white_on_yellow + text[0] else:colored_text += normal + text[0] if 'A' <= text[1] <= 'Z': colored_text += white_on_yellow + text[1] else:colored_text += normal + text[1] if 'A' <= text[2] <= 'Z': colored_text += white_on_yellow + text[2] else:colored_text += normal + text[2] if 'A' <= text[3] <= 'Z': colored_text += white_on_yellow + text[3] else:colored_text += normal + text[3] if 'A' <= text[4] <= 'Z': colored_text += white_on_yellow + text[4] + normal else:colored_text += normal + text[4] return colored_text# 6430438821 sim = 74.27% import random import string def position_in_word(ch, word): if ch in word: if word[0] == ch: xx = 0 elif word[1] == ch: xx = 1 elif word[2] == ch: xx = 2 elif word[3] == ch: xx = 3 elif word[4] == ch: xx = 4 elif word[5] == ch: xx = 5 else: xx = -1 position = xx return position def check_correct_position(puzzle_word, guess_word): correct = '' new_puzzle_word = '' new_guess_word = '' if guess_word[0] == puzzle_word[0]: new_guess_word +="-" correct +=puzzle_word[0] new_puzzle_word +="-" else: new_guess_word += guess_word[0] correct +="?" new_puzzle_word +=puzzle_word[0] if guess_word[1] == puzzle_word[1]: new_guess_word +="-" correct +=puzzle_word[1] new_puzzle_word +="-" else: new_guess_word +=guess_word[1] correct +="?" new_puzzle_word +=puzzle_word[1] if guess_word[2] == puzzle_word[2]: new_guess_word +="-" correct +=puzzle_word[2] new_puzzle_word +="-" else: new_guess_word +=guess_word[2] correct +="?" new_puzzle_word +=puzzle_word[2] if guess_word[3] == puzzle_word[3]: new_guess_word +="-" correct +=puzzle_word[3] new_puzzle_word +="-" else: new_guess_word +=guess_word[3] correct +="?" new_puzzle_word +=puzzle_word[3] if guess_word[4] == puzzle_word[4]: new_guess_word +="-" correct +=puzzle_word[4] new_puzzle_word +="-" else: new_guess_word +=guess_word[4] correct +="?" new_puzzle_word +=puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): if guess_word[0] in puzzle_word and guess_word[0] != "-": guess_word += guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word,position_in_word(guess_word[0], puzzle_word), "-") else: guess_word +="*" if guess_word[1] in puzzle_word and guess_word[1] != "-": guess_word += guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), "-") else: guess_word +="*" if guess_word[2] in puzzle_word and guess_word[2] != "-": guess_word += guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), "-") else: guess_word +="*" if guess_word[3] in puzzle_word and guess_word[3] != "-": guess_word += guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3],puzzle_word), "-") else: guess_word +="*" if guess_word[4] in puzzle_word and guess_word[4] != "-": guess_word += guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), "-") else: guess_word +="*" wrong_position = guess_word[5::] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): new_str = '' k = int(k) new_str += original_str[0:k] + ch + original_str[k+1::] return new_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' new_text = '' if color == "green": if 'A' <= text[0] <= 'Z': new_text += white_on_green + text[0] + normal else: new_text += text[0] if 'A' <= text[1] <= 'Z': new_text += white_on_green + text[1] + normal else: new_text += text[1] if 'A' <= text[2] <= 'Z': new_text += white_on_green + text[2] + normal else: new_text += text[2] if 'A' <= text[3] <= 'Z': new_text += white_on_green + text[3] + normal else: new_text += text[3] if 'A' <= text[4] <= 'Z': new_text += white_on_green + text[4] + normal else: new_text += text[4] else: if 'A' <= text[0] <= 'Z': new_text += white_on_yellow + text[0] + normal else: new_text += text[0] if 'A' <= text[1] <= 'Z': new_text += white_on_yellow + text[1] + normal else: new_text += text[1] if 'A' <= text[2] <= 'Z': new_text += white_on_yellow + text[2] + normal else: new_text += text[2] if 'A' <= text[3] <= 'Z': new_text += white_on_yellow + text[3] + normal else: new_text += text[3] if 'A' <= text[4] <= 'Z': new_text += white_on_yellow + text[4] + normal else: new_text += text[4] colored_text = new_text return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #15(4)

# 6231225421 sim = 74.07% import random import string def position_in_word(ch, word): position = -1 if ch == word[0] : return 0 elif ch == word[1] : return 1 elif ch == word[2] : return 2 elif ch == word[3] : return 3 elif ch == word[4] : return 4 else : return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0] : correct = guess_word[0]+correct[1:] new_puzzle_word = '-'+new_puzzle_word[1:] new_guess_word = '-'+new_guess_word[1:] if guess_word[1] == puzzle_word[1] : correct = correct[0:1]+new_guess_word[1]+correct[2:] new_puzzle_word = new_puzzle_word[0:1]+'-'+new_puzzle_word[2:] new_guess_word = new_guess_word[0:1]+'-'+new_guess_word[2:] if guess_word[2] == puzzle_word[2] : correct = correct[0:2]+guess_word[2]+correct[3:] new_puzzle_word = new_puzzle_word[0:2]+'-'+new_puzzle_word[3:] new_guess_word = new_guess_word[0:2]+'-'+new_guess_word[3:] if guess_word[3] == puzzle_word[3] : correct = correct[0:3]+guess_word[3]+correct[4:] new_puzzle_word = new_puzzle_word[0:3]+'-'+new_puzzle_word[4:] new_guess_word = new_guess_word[0:3]+'-'+new_guess_word[4:] if guess_word[4] == puzzle_word[4] : correct = correct[0:4]+guess_word[4] new_puzzle_word = new_puzzle_word[0:4]+'-' new_guess_word = new_guess_word[0:4]+'-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if ('A'<=guess_word[0]<='Z') and (guess_word[0] in puzzle_word) : if guess_word[0] == puzzle_word[1]: puzzle_word = puzzle_word[0:1]+'-'+puzzle_word[2:] wrong_position = guess_word[0]+wrong_position[1:] elif guess_word[0] == puzzle_word[2]: puzzle_word = puzzle_word[0:2]+'-'+puzzle_word[3:] wrong_position = guess_word[0]+wrong_position[1:] elif guess_word[0] == puzzle_word[3]: puzzle_word = puzzle_word[0:3]+'-'+puzzle_word[4:] wrong_position = guess_word[0]+wrong_position[1:] elif guess_word[0] == puzzle_word[4]: puzzle_word = puzzle_word[0:4]+'-' wrong_position = guess_word[0]+wrong_position[1:] if ('A'<=guess_word[1]<='Z') and (guess_word[1] in puzzle_word) : if guess_word[1] == puzzle_word[0]: puzzle_word = '-'+puzzle_word[1:] wrong_position = wrong_position[0:1]+guess_word[1]+wrong_position[2:] elif guess_word[1] == puzzle_word[2]: puzzle_word = puzzle_word[0:2]+'-'+puzzle_word[3:] wrong_position = wrong_position[0:1]+guess_word[1]+wrong_position[2:] elif guess_word[1] == puzzle_word[3]: puzzle_word = puzzle_word[0:3]+'-'+puzzle_word[4:] wrong_position = wrong_position[0:1]+guess_word[1]+wrong_position[2:] elif guess_word[1] == puzzle_word[4]: puzzle_word = puzzle_word[0:4]+'-' wrong_position = wrong_position[0:1]+guess_word[1]+wrong_position[2:] if ('A'<=guess_word[2]<='Z') and (guess_word[2] in puzzle_word) : if guess_word[2] == puzzle_word[0]: puzzle_word = '-'+puzzle_word[1:] wrong_position = wrong_position[0:2]+guess_word[2]+wrong_position[3:] elif guess_word[2] == puzzle_word[1]: puzzle_word = puzzle_word[0:1]+'-'+puzzle_word[2:] wrong_position = wrong_position[0:2]+guess_word[2]+wrong_position[3:] elif guess_word[2] == puzzle_word[3]: puzzle_word = puzzle_word[0:3]+'-'+puzzle_word[4:] wrong_position = wrong_position[0:2]+guess_word[2]+wrong_position[3:] elif guess_word[2] == puzzle_word[4]: puzzle_word = puzzle_word[0:4]+'-' wrong_position = wrong_position[0:2]+guess_word[2]+wrong_position[3:] if ('A'<=guess_word[3]<='Z') and (guess_word[3] in puzzle_word) : if guess_word[3] == puzzle_word[0]: puzzle_word = '-'+puzzle_word[1:] wrong_position = wrong_position[0:3]+guess_word[3]+wrong_position[4:] elif guess_word[3] == puzzle_word[1]: puzzle_word = puzzle_word[0:1]+'-'+puzzle_word[2:] wrong_position = wrong_position[0:3]+guess_word[3]+wrong_position[4:] elif guess_word[3] == puzzle_word[2]: puzzle_word = puzzle_word[0:2]+'-'+puzzle_word[3:] wrong_position = wrong_position[0:3]+guess_word[3]+wrong_position[4:] elif guess_word[3] == puzzle_word[4]: puzzle_word = puzzle_word[0:4]+'-' wrong_position = wrong_position[0:3]+guess_word[3]+wrong_position[4:] if ('A'<=guess_word[4]<='Z') and (guess_word[4] in puzzle_word) : if guess_word[4] == puzzle_word[0]: puzzle_word = '-'+puzzle_word[1:] wrong_position = wrong_position[0:4]+guess_word[4] elif guess_word[4] == puzzle_word[1]: puzzle_word = puzzle_word[0:1]+'-'+puzzle_word[2:] wrong_position = wrong_position[0:4]+guess_word[4] elif guess_word[4] == puzzle_word[2]: puzzle_word = puzzle_word[0:2]+'-'+puzzle_word[3:] wrong_position = wrong_position[0:4]+guess_word[4] elif guess_word[4] == puzzle_word[3]: puzzle_word = puzzle_word[0:3]+'-'+puzzle_word[4:] wrong_position = wrong_position[0:4]+guess_word[4] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 4 : replace = original_str[0:4]+ch else : replace = original_str[0:k]+ch+original_str[k+1:] return replace def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green' : if 'A'<=text[0].upper()<='Z' : colored_text += white_on_green+text[0].upper()+normal else : colored_text += text[0] if 'A'<=text[1].upper()<='Z' : colored_text += white_on_green+text[1].upper()+normal else : colored_text += text[1] if 'A'<=text[2].upper()<='Z' : colored_text += white_on_green+text[2].upper()+normal else : colored_text += text[2] if 'A'<=text[3].upper()<='Z' : colored_text += white_on_green+text[3].upper()+normal else : colored_text += text[3] if 'A'<=text[4].upper()<='Z' : colored_text += white_on_green+text[4].upper()+normal else : colored_text += text[4] elif color =='yellow' : if 'A'<=text[0].upper()<='Z' : colored_text += white_on_yellow+text[0].upper()+normal else : colored_text += text[0] if 'A'<=text[1].upper()<='Z' : colored_text += white_on_yellow+text[1].upper()+normal else : colored_text += text[1] if 'A'<=text[2].upper()<='Z' : colored_text += white_on_yellow+text[2].upper()+normal else : colored_text += text[2] if 'A'<=text[3].upper()<='Z' : colored_text += white_on_yellow+text[3].upper()+normal else : colored_text += text[3] if 'A'<=text[4].upper()<='Z' : colored_text += white_on_yellow+text[4].upper()+normal else : colored_text += text[4] return colored_text# 6432129221 sim = 74.07% import random import string def position_in_word(ch, word): if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' if puzzle_word[0] == guess_word[0] : guess_word = '-'+guess_word[1:] correct = puzzle_word[0]+correct[1:] puzzle_word = '-'+puzzle_word[1:] if puzzle_word[1] == guess_word[1] : guess_word = guess_word[0]+'-'+guess_word[2:] correct = correct[0]+puzzle_word[1]+correct[2:] puzzle_word = puzzle_word[0]+'-'+puzzle_word[2:] if puzzle_word[2] == guess_word[2] : guess_word = guess_word[0:2]+'-'+guess_word[3:] correct = correct[0:2]+puzzle_word[2]+correct[3:] puzzle_word = puzzle_word[0:2]+'-'+puzzle_word[3:] if puzzle_word[3] == guess_word[3] : guess_word = guess_word[0:3]+'-'+guess_word[4:] correct = correct[0:3]+puzzle_word[3]+correct[4:] puzzle_word = puzzle_word[0:3]+'-'+puzzle_word[4:] if puzzle_word[4] == guess_word[4] : guess_word = guess_word[0:4]+'-' correct = correct[0:4]+puzzle_word[4] puzzle_word = puzzle_word[0:4]+'-' new_guess_word = guess_word new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if 'A' <= guess_word[0] <= 'Z' : if guess_word[0] == puzzle_word[1] : puzzle_word = puzzle_word[0]+'-'+puzzle_word[2:] wrong_position = guess_word[0] + wrong_position[1:] elif guess_word[0] == puzzle_word[2] : puzzle_word = puzzle_word[0:2]+'-'+puzzle_word[3:] wrong_position = guess_word[0] + wrong_position[1:] elif guess_word[0] == puzzle_word[3] : puzzle_word = puzzle_word[0:3]+'-'+puzzle_word[4] wrong_position = guess_word[0] + wrong_position[1:] elif guess_word[0] == puzzle_word[4] : puzzle_word = puzzle_word[0:4]+'-' wrong_position = guess_word[0] + wrong_position[1:] if 'A' <= guess_word[1] <= 'Z' : if guess_word[1] == puzzle_word[0] : puzzle_word = '-'+puzzle_word[1:] wrong_position = wrong_position[0]+ guess_word[1] + wrong_position[2:] elif guess_word[1] == puzzle_word[2] : puzzle_word = puzzle_word[0:2]+'-'+puzzle_word[3:] wrong_position = wrong_position[0]+ guess_word[1] + wrong_position[2:] elif guess_word[1] == puzzle_word[3] : puzzle_word = puzzle_word[0:3]+'-'+puzzle_word[4] wrong_position = wrong_position[0]+ guess_word[1] + wrong_position[2:] elif guess_word[1] == puzzle_word[4] : puzzle_word = puzzle_word[0:4]+'-' wrong_position = wrong_position[0]+ guess_word[1] + wrong_position[2:] if 'A' <= guess_word[2] <= 'Z' : if guess_word[2] == puzzle_word[0] : puzzle_word = '-'+puzzle_word[1:] wrong_position = wrong_position[0:2]+ guess_word[2] + wrong_position[3:] elif guess_word[2] == puzzle_word[1] : puzzle_word = puzzle_word[0]+'-'+puzzle_word[2:] wrong_position = wrong_position[0:2]+ guess_word[2] + wrong_position[3:] elif guess_word[2] == puzzle_word[3] : puzzle_word = puzzle_word[0:3]+'-'+puzzle_word[4] wrong_position = wrong_position[0:2]+ guess_word[2] + wrong_position[3:] elif guess_word[2] == puzzle_word[4] : puzzle_word = puzzle_word[0:4]+'-' wrong_position = wrong_position[0:2]+ guess_word[2] + wrong_position[3:] if 'A' <= guess_word[3] <= 'Z' : if guess_word[3] == puzzle_word[0] : puzzle_word = '-'+puzzle_word[1:] wrong_position = wrong_position[0:3]+ guess_word[3] + wrong_position[4] elif guess_word[3] == puzzle_word[1] : puzzle_word = puzzle_word[0]+'-'+puzzle_word[2:] wrong_position = wrong_position[0:3]+ guess_word[3] + wrong_position[4] elif guess_word[3] == puzzle_word[2] : puzzle_word = puzzle_word[0:2]+'-'+puzzle_word[3:] wrong_position = wrong_position[0:3]+ guess_word[3] + wrong_position[4] elif guess_word[3] == puzzle_word[4] : puzzle_word = puzzle_word[0:4]+'-' wrong_position = wrong_position[0:3]+ guess_word[3] + wrong_position[4] if 'A' <= guess_word[4] <= 'Z' : if guess_word[4] == puzzle_word[0] : puzzle_word = '-'+puzzle_word[1:] wrong_position = wrong_position[0:4]+ guess_word[4] elif guess_word[4] == puzzle_word[1] : puzzle_word = puzzle_word[0]+'-'+puzzle_word[2:] wrong_position = wrong_position[0:4]+ guess_word[4] elif guess_word[4] == puzzle_word[2] : puzzle_word = puzzle_word[0:2]+'-'+puzzle_word[3:] wrong_position = wrong_position[0:4]+ guess_word[4] elif guess_word[4] == puzzle_word[3] : puzzle_word = puzzle_word[0:3]+'-'+puzzle_word[4] wrong_position = wrong_position[0:4]+ guess_word[4] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0 : string = '-'+original_str[1:] if k == 1 : string = original_str[0]+ch+original_str[2:] if k == 2 : string = original_str[0:2]+ch+original_str[3:] if k == 3 : string = original_str[0:3]+ch+original_str[4] if k == 4 : string = original_str[0:4]+ch return string def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == 'green' : ch1 = text[0] if 'A' <= ch1 <= 'Z' : ch1 = white_on_green+ch1+normal ch2 = text[1] if 'A' <= ch2 <= 'Z' : ch2 = white_on_green+ch2+normal ch3 = text[2] if 'A' <= ch3 <= 'Z' : ch3 = white_on_green+ch3+normal ch4 = text[3] if 'A' <= ch4 <= 'Z' : ch4 = white_on_green+ch4+normal ch5 = text[4] if 'A' <= ch5 <= 'Z' : ch5 = white_on_green+ch5+normal text = ch1+ch2+ch3+ch4+ch5 elif color == 'yellow': ch1 = text[0] if 'A' <= ch1 <= 'Z' : ch1 = white_on_yellow+ch1+normal ch2 = text[1] if 'A' <= ch2 <= 'Z' : ch2 = white_on_yellow+ch2+normal ch3 = text[2] if 'A' <= ch3 <= 'Z' : ch3 = white_on_yellow+ch3+normal ch4 = text[3] if 'A' <= ch4 <= 'Z' : ch4 = white_on_yellow+ch4+normal ch5 = text[4] if 'A' <= ch5 <= 'Z' : ch5 = white_on_yellow+ch5+normal text = ch1+ch2+ch3+ch4+ch5 colored_text = text return colored_text# 6430381621 sim = 73.36% import random import string def position_in_word(ch, word): if ch[0] in word : position = 0 elif ch[1] in word : position = 1 elif ch[2] in word : position = 2 elif ch[3] in word : position = 3 elif ch not in word : position = -1 return position def check_correct_position(puzzle_word, guess_word): show = '?????' if guess_word[0] == puzzle_word[0] : guess_word = '-' + guess_word[1:] show = puzzle_word[0] + show[1:] puzzle_word = '-' + puzzle_word[1:] if guess_word[1] == puzzle_word[1] : guess_word = guess_word[0] + '-' + guess_word[2:] show = show[0] + puzzle_word[1] + show[2:] puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] if guess_word[2] == puzzle_word[2] : guess_word = guess_word[0:2] + '-' + guess_word[3:] show = show[0:2] + puzzle_word[2] + show[3:] puzzle_word = puzzle_word[0:2] + '-' + puzzle_word[3:] if guess_word[3] == puzzle_word[3] : guess_word = guess_word[0:3] + '-' + guess_word[4:] show = show[0:3] + puzzle_word[3] + show[4:] puzzle_word = puzzle_word[0:3] + '-' + puzzle_word[4:] if guess_word[4] == puzzle_word[4] : guess_word = guess_word[0:4] + '-' show = show[0:4] + puzzle_word[4] puzzle_word = puzzle_word[0:4] + '-' new_guess_word = guess_word correct = show new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] in puzzle_word[1:] : if guess_word[0] == puzzle_word[1] : puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] elif guess_word[0] == puzzle_word[2] : puzzle_word = puzzle_word[0:2] + '-' + puzzle_word[3:] elif guess_word[0] == puzzle_word[3] : puzzle_word = puzzle_word[0:3] + '-' + puzzle_word[4] elif guess_word[0] == puzzle_word[4] : puzzle_word = puzzle_word[0:4] + '-' if 'A' <= guess_word[0] <= 'Z' : wrong_position = guess_word[0] + wrong_position[1:] if guess_word[1] == puzzle_word[0] or guess_word[1] in puzzle_word[2:] : if guess_word[1] == puzzle_word[0] : puzzle_word = '-' + puzzle_word[1:] elif guess_word[1] == puzzle_word[2] : puzzle_word = puzzle_word[0:2] + '-' + puzzle_word[3:] elif guess_word[1] == puzzle_word[3] : puzzle_word = puzzle_word[0:3] + '-' + puzzle_word[4] elif guess_word[1] == puzzle_word[4] : puzzle_word = puzzle_word[0:4] + '-' if 'A' <= guess_word[1] <= 'Z' : wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] if guess_word[2] in puzzle_word[0:2] or guess_word[2] in puzzle_word[3:] : if guess_word[2] == puzzle_word[0] : puzzle_word = '-' + puzzle_word[1:] elif guess_word[2] == puzzle_word[1] : puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] elif guess_word[2] == puzzle_word[3] : puzzle_word = puzzle_word[0:3] + '-' + puzzle_word[4] elif guess_word[2] == puzzle_word[4] : puzzle_word = puzzle_word[0:4] + '-' if 'A' <= guess_word[2] <= 'Z' : wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:] if guess_word[3] in puzzle_word[0:3] or guess_word[3] == puzzle_word[4] : if guess_word[3] == puzzle_word[0] : puzzle_word = '-' + puzzle_word[1:] elif guess_word[3] == puzzle_word[1] : puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] elif guess_word[3] == puzzle_word[2] : puzzle_word = puzzle_word[0:2] + '-' + puzzle_word[3:] elif guess_word[3] == puzzle_word[4] : puzzle_word = puzzle_word[0:4] + '-' if 'A' <= guess_word[3] <= 'Z' : wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4] if guess_word[4] in puzzle_word[:4] : if guess_word[4] == puzzle_word[0] : puzzle_word = '-' + puzzle_word[1:] elif guess_word[4] == puzzle_word[1] : puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] elif guess_word[4] == puzzle_word[2] : puzzle_word = puzzle_word[0:2] + '-' + puzzle_word[3:] elif guess_word[4] == puzzle_word[3] : puzzle_word = puzzle_word[0:3] + '-' + puzzle_word[4] if 'A' <= guess_word[4] <= 'Z' : wrong_position = wrong_position[0:4] + guess_word[4] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0 : replace_kth_letter_in_str = ch + original_str[1:] elif k == 1 : replace_kth_letter_in_str = original_str[0] + ch + original_str[2:] elif k == 2 : replace_kth_letter_in_str = original_str[0:2] + ch + original_str[3:] elif k == 3 : replace_kth_letter_in_str = original_str[0:3] + ch + original_str[4:] elif k == 4 : replace_kth_letter_in_str = original_str[0:4] + ch return replace_kth_letter_in_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' ch1 = text[0] ch2 = text[1] ch3 = text[2] ch4 = text[3] ch5 = text[4] if color == 'green' : green = white_on_green if 'A' <= text[0] <= 'Z' : ch1 = green + text[0] + normal if 'A' <= text[1] <= 'Z' : ch2 = green + text[1] + normal if 'A' <= text[2] <= 'Z' : ch3 = green + text[2] + normal if 'A' <= text[3] <= 'Z' : ch4 = green + text[3] + normal if 'A' <= text[4] <= 'Z' : ch5 = green + text[4] + normal if color == 'yellow' : yellow = white_on_yellow if 'A' <= text[0] <= 'Z' : ch1 = yellow + text[0] + normal if 'A' <= text[1] <= 'Z' : ch2 = yellow + text[1] + normal if 'A' <= text[2] <= 'Z' : ch3 = yellow + text[2] + normal if 'A' <= text[3] <= 'Z' : ch4 = yellow + text[3] + normal if 'A' <= text[4] <= 'Z' : ch5 = yellow + text[4] + normal text = ch1+ch2+ch3+ch4+ch5 colored_text = text return colored_text# 6430403821 sim = 73.36% import random import string def position_in_word(ch, word): if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' if puzzle_word[0] == guess_word[0] : guess_word = '-' + guess_word[1:] correct = puzzle_word[0] + correct[1:] puzzle_word = '-' + puzzle_word[1:] if puzzle_word[1] == guess_word[1] : guess_word = guess_word[0] + '-' + guess_word[2:] correct = correct[0] + puzzle_word[1] + correct[2:] puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] if puzzle_word[2] == guess_word[2] : guess_word = guess_word[0:2] + '-' + guess_word[3:] correct = correct[0:2] + puzzle_word[2] + correct[3:] puzzle_word = puzzle_word[0:2] + '-' + puzzle_word[3:] if puzzle_word[3] == guess_word[3] : guess_word = guess_word[0:3] + '-' + guess_word[4:] correct = correct[0:3] + puzzle_word[3] + correct[4:] puzzle_word = puzzle_word[0:3] + '-' + puzzle_word[4:] if puzzle_word[4] == guess_word[4] : guess_word = guess_word[0:4] + '-' correct = correct[0:4] + puzzle_word[4] puzzle_word = puzzle_word[0:4] + '-' new_guess_word = guess_word new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] in puzzle_word[1:] : if puzzle_word[0] == guess_word[0] : puzzle_word = '-' + puzzle_word[1:] elif puzzle_word[1] == guess_word[0] : puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] elif puzzle_word[2] == guess_word[0] : puzzle_word = puzzle_word[0:2] + '-' + puzzle_word[3:] elif puzzle_word[3] == guess_word[0] : puzzle_word = puzzle_word[0:3] + '-' + puzzle_word[4:] elif puzzle_word[4] == guess_word[0] : puzzle_word = puzzle_word[0:4] + '-' if 'A' <= guess_word[0] <= 'Z' : wrong_position = guess_word[0] + wrong_position[1:] if guess_word[1] in (puzzle_word[0] + puzzle_word[2:]) : if puzzle_word[0] == guess_word[1] : puzzle_word = '-' + puzzle_word[1:] elif puzzle_word[1] == guess_word[1] : puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] elif puzzle_word[2] == guess_word[1] : puzzle_word = puzzle_word[0:2] + '-' + puzzle_word[3:] elif puzzle_word[3] == guess_word[1] : puzzle_word = puzzle_word[0:3] + '-' + puzzle_word[4:] elif puzzle_word[4] == guess_word[1] : puzzle_word = puzzle_word[0:4] + '-' if 'A' <= guess_word[1] <= 'Z' : wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] if guess_word[2] in (puzzle_word[0:2] + puzzle_word[3:]) : if puzzle_word[0] == guess_word[2] : puzzle_word = '-' + puzzle_word[1:] elif puzzle_word[1] == guess_word[2] : puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] elif puzzle_word[2] == guess_word[2] : puzzle_word = puzzle_word[0:2] + '-' + puzzle_word[3:] elif puzzle_word[3] == guess_word[2] : puzzle_word = puzzle_word[0:3] + '-' + puzzle_word[4:] elif puzzle_word[4] == guess_word[2] : puzzle_word = puzzle_word[0:4] + '-' if 'A' <= guess_word[2] <= 'Z' : wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:] if guess_word[3] in (puzzle_word[0:3] + puzzle_word[4:]) : if puzzle_word[0] == guess_word[3] : puzzle_word = '-' + puzzle_word[1:] elif puzzle_word[1] == guess_word[3] : puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] elif puzzle_word[2] == guess_word[3] : puzzle_word = puzzle_word[0:2] + '-' + puzzle_word[3:] elif puzzle_word[3] == guess_word[3] : puzzle_word = puzzle_word[0:3] + '-' + puzzle_word[4:] elif puzzle_word[4] == guess_word[3] : puzzle_word = puzzle_word[0:4] + '-' if 'A' <= guess_word[3] <= 'Z' : wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4:] if guess_word[4] in puzzle_word[0:4] : if puzzle_word[0] == guess_word[4] : puzzle_word = '-' + puzzle_word[1:] elif puzzle_word[1] == guess_word[4] : puzzle_word = puzzle_word[0] + '-' + puzzle_word[2:] elif puzzle_word[2] == guess_word[4] : puzzle_word = puzzle_word[0:2] + '-' + puzzle_word[3:] elif puzzle_word[3] == guess_word[4] : puzzle_word = puzzle_word[0:3] + '-' + puzzle_word[4:] elif puzzle_word[4] == guess_word[4] : puzzle_word = puzzle_word[0:4] + '-' if 'A' <= guess_word[4] <= 'Z' : wrong_position = wrong_position[0:4] + guess_word[4] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0 : changed_str = '-' + original_str[1:] elif k == 1 : changed_str = original_str[0] + ch + original_str[2:] elif k == 2 : changed_str = original_str[0:2] + ch + original_str[3:] elif k == 3 : changed_str = original_str[0:3] + ch + original_str[4:] elif k == 4 : changed_str = original_str[0:4] + ch return changed_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == 'green' : change_to = white_on_green ch1 = text[0] if 'A' <= text[0] <= 'Z' : ch1 = change_to + text[0] + normal ch2 = text[1] if 'A' <= text[1] <= 'Z' : ch2 = change_to + text[1] + normal ch3 = text[2] if 'A' <= text[2] <= 'Z' : ch3 = change_to + text[2] + normal ch4 = text[3] if 'A' <= text[3] <= 'Z' : ch4 = change_to + text[3] + normal ch5 = text[4] if 'A' <= text[4] <= 'Z' : ch5 = change_to + text[4] + normal text = ch1 + ch2 + ch3 + ch4 + ch5 elif color == 'yellow' : change_to = white_on_yellow ch1 = text[0] if 'A' <= text[0] <= 'Z' : ch1 = change_to + text[0] + normal ch2 = text[1] if 'A' <= text[1] <= 'Z' : ch2 = change_to + text[1] + normal ch3 = text[2] if 'A' <= text[2] <= 'Z' : ch3 = change_to + text[2] + normal ch4 = text[3] if 'A' <= text[3] <= 'Z' : ch4 = change_to + text[3] + normal ch5 = text[4] if 'A' <= text[4] <= 'Z' : ch5 = change_to + text[4] + normal text = ch1 + ch2 + ch3 + ch4 + ch5 colored_text = text return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #16(2)

# 6432063421 sim = 73.83% import random import string def position_in_word(ch, word): position = -1 if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : pass return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0] : new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,0,'-') new_guess_word = replace_kth_letter_in_str(new_guess_word,0,'-') correct += puzzle_word[0] else : correct += '?' if puzzle_word[1] == guess_word[1] : new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,1,'-') new_guess_word = replace_kth_letter_in_str(new_guess_word,1,'-') correct += puzzle_word[1] else : correct += '?' if puzzle_word[2] == guess_word[2] : new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,2,'-') new_guess_word = replace_kth_letter_in_str(new_guess_word,2,'-') correct += puzzle_word[2] else : correct += '?' if puzzle_word[3] == guess_word[3] : new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,3,'-') new_guess_word = replace_kth_letter_in_str(new_guess_word,3,'-') correct += puzzle_word[3] else : correct += '?' if puzzle_word[4] == guess_word[4] : new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word,4,'-') new_guess_word = replace_kth_letter_in_str(new_guess_word,4,'-') correct += puzzle_word[4] else : correct += '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return str(original_str[:k] + ch + original_str[k+1:]) def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] != '-' and guess_word[0] in puzzle_word : wrong_position += guess_word[0] puzzle_word = replace_letter(puzzle_word,guess_word[0],'=') else : wrong_position += '*' if guess_word[1] != '-' and guess_word[1] in puzzle_word : wrong_position += guess_word[1] puzzle_word = replace_letter(puzzle_word,guess_word[1],'=') else : wrong_position += '*' if guess_word[2] != '-' and guess_word[2] in puzzle_word : wrong_position += guess_word[2] puzzle_word = replace_letter(puzzle_word,guess_word[2],'=') else : wrong_position += '*' if guess_word[3] != '-' and guess_word[3] in puzzle_word : wrong_position += guess_word[3] puzzle_word = replace_letter(puzzle_word,guess_word[3],'=') else : wrong_position += '*' if guess_word[4] != '-' and guess_word[4] in puzzle_word : wrong_position += guess_word[4] puzzle_word = replace_letter(puzzle_word,guess_word[4],'=') else : wrong_position += '*' return wrong_position def replace_letter(original, old_letter, new_letter): if old_letter in original: k = original.find(old_letter) original = original[:k] + new_letter + original[k+1:] return original def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' sign = ['*','?'] if color == 'green' : if not( text[0] in sign ) : colored_text += white_on_green + text[0] + normal else : colored_text += text[0] if not( text[1] in sign ) : colored_text += white_on_green +text[1] + normal else : colored_text += text[1] if not( text[2] in sign ) : colored_text += white_on_green +text[2] + normal else : colored_text += text[2] if not( text[3] in sign ) : colored_text += white_on_green +text[3] + normal else : colored_text += text[3] if not( text[4] in sign ) : colored_text += white_on_green +text[4] + normal else : colored_text += text[4] else : if not( text[0] in sign ) : colored_text += white_on_yellow +text[0] + normal else : colored_text += text[0] if not( text[1] in sign ) : colored_text += white_on_yellow +text[1] + normal else : colored_text += text[1] if not( text[2] in sign ) : colored_text += white_on_yellow +text[2] + normal else : colored_text += text[2] if not( text[3] in sign ) : colored_text += white_on_yellow +text[3] + normal else : colored_text += text[3] if not( text[4] in sign ) : colored_text += white_on_yellow +text[4] + normal else : colored_text += text[4] return colored_text# 6432068621 sim = 73.83% import random import string def position_in_word(ch, word): position = -1 if word[0]== ch: position=0 elif word[1]==ch: position=1 elif word[2]==ch: position=2 elif word[3]==ch: position=3 elif word[4]== ch: position=4 else:None return position def check_correct_position(puzzle_word, guess_word): correct = '' new_guess_word=guess_word if puzzle_word[0]==guess_word[0]: new_guess_word= replace_kth_letter_in_str(new_guess_word,0,'-') correct = correct+puzzle_word[0] puzzle_word=replace_kth_letter_in_str(puzzle_word,0,'-') else: correct += '?' if puzzle_word[1]==guess_word[1]: new_guess_word= replace_kth_letter_in_str(new_guess_word,1,'-') correct = correct+puzzle_word[1] puzzle_word=replace_kth_letter_in_str(puzzle_word,1,'-') else: correct += '?' if puzzle_word[2]==guess_word[2]: new_guess_word= replace_kth_letter_in_str(new_guess_word,2,'-') correct = correct+puzzle_word[2] puzzle_word=replace_kth_letter_in_str(puzzle_word,2,'-') else: correct += '?' if puzzle_word[3]==guess_word[3]: new_guess_word= replace_kth_letter_in_str(new_guess_word,3,'-') correct = correct+puzzle_word[3] puzzle_word=replace_kth_letter_in_str(puzzle_word,3,'-') else: correct += '?' if puzzle_word[4]==guess_word[4]: new_guess_word= replace_kth_letter_in_str(new_guess_word,4,'-') correct = correct+puzzle_word[4] puzzle_word=replace_kth_letter_in_str(puzzle_word,4,'-') else: correct += '?' new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): new_str=original_str[:k]+ch+original_str[k+1:] return '{}'.format(new_str) def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] !=puzzle_word[0]: wrong_position += guess_word[0] puzzle_word =replace_letter(puzzle_word,guess_word[0],'-') else:wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] !=puzzle_word[1]: wrong_position += guess_word[1] puzzle_word =replace_letter(puzzle_word,guess_word[1],'-') else:wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] !=puzzle_word[2]: wrong_position += guess_word[2] puzzle_word =replace_letter(puzzle_word,guess_word[2],'-') else:wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] !=puzzle_word[3]: wrong_position += guess_word[3] puzzle_word =replace_letter(puzzle_word,guess_word[3],'-') else:wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] !=puzzle_word[4]: wrong_position += guess_word[4] puzzle_word =replace_letter(puzzle_word,guess_word[4],'-') else:wrong_position += '*' return wrong_position def replace_letter(original, old_letter, new_letter): if old_letter in original: k = original.find(old_letter) original = original[:k] + new_letter + original[k+1:] return original def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green': if text[0] != '*' and text[0] != '?': text0= white_on_green + text[0]+normal else:text0=text[0] if text[1] !='*' and text[1] != '?': text1= white_on_green +text[1]+normal else:text1=text[1] if text[2] !='*' and text[2] != '?': text2= white_on_green +text[2]+normal else:text2=text[2] if text[3] !='*' and text[3] != '?': text3= white_on_green +text[3]+normal else:text3=text[3] if text[4] !='*' and text[4] != '?': text4= white_on_green +text[4]+normal else:text4=text[4] else: if text[0] !='*' and text[0] != '?': text0= white_on_yellow +text[0]+normal else:text0=text[0] if text[1] !='*' and text[1] != '?': text1= white_on_yellow +text[1]+normal else:text1=text[1] if text[2] !='*' and text[2] != '?': text2= white_on_yellow +text[2]+normal else:text2=text[2] if text[3] !='*' and text[3] != '?': text3= white_on_yellow +text[3]+normal else:text3=text[3] if text[4] !='*' and text[4] != '?': text4= white_on_yellow +text[4]+normal else:text4=text[4] colored_text = '{}{}{}{}{}'.format(text0,text1,text2,text3,text4) return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #17(3)

# 6430339321 sim = 73.52% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: guess_word = replace_kth_letter_in_str(guess_word,0,'-') correct = replace_kth_letter_in_str(correct,0,puzzle_word[0]) puzzle_word = replace_kth_letter_in_str(puzzle_word,0,'-') if guess_word[1] == puzzle_word[1]: guess_word = replace_kth_letter_in_str(guess_word,1,'-') correct = replace_kth_letter_in_str(correct,1,puzzle_word[1]) puzzle_word = replace_kth_letter_in_str(puzzle_word,1,'-') if guess_word[2] == puzzle_word[2]: guess_word = replace_kth_letter_in_str(guess_word,2,'-') correct = replace_kth_letter_in_str(correct,2,puzzle_word[2]) puzzle_word = replace_kth_letter_in_str(puzzle_word,2,'-') if guess_word[3] == puzzle_word[3]: guess_word = replace_kth_letter_in_str(guess_word,3,'-') correct = replace_kth_letter_in_str(correct,3,puzzle_word[3]) puzzle_word = replace_kth_letter_in_str(puzzle_word,3,'-') if guess_word[4] == puzzle_word[4]: guess_word = replace_kth_letter_in_str(guess_word,4,'-') correct = replace_kth_letter_in_str(correct,4,puzzle_word[4]) puzzle_word = replace_kth_letter_in_str(puzzle_word,4,'-') new_puzzle_word = puzzle_word new_guess_word = guess_word return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): s = original_str s = s[0:k]+ch+s[k+1:] return s def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] in puzzle_word and guess_word[0] != '-': wrong_position = replace_kth_letter_in_str(wrong_position, 0, guess_word[0]) if puzzle_word[0] == guess_word[0]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '/') elif puzzle_word[1] == guess_word[0]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '/') elif puzzle_word[2] == guess_word[0]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '/') elif puzzle_word[3] == guess_word[0]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '/') elif puzzle_word[4] == guess_word[0]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '/') if guess_word[1] in puzzle_word and guess_word[1] != '-': wrong_position = replace_kth_letter_in_str(wrong_position, 1, guess_word[1]) if puzzle_word[0] == guess_word[1]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '/') elif puzzle_word[1] == guess_word[1]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '/') elif puzzle_word[2] == guess_word[1]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '/') elif puzzle_word[3] == guess_word[1]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '/') elif puzzle_word[4] == guess_word[1]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '/') if guess_word[2] in puzzle_word and guess_word[2] != '-': wrong_position = replace_kth_letter_in_str(wrong_position, 2, guess_word[2]) if puzzle_word[0] == guess_word[2]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '/') elif puzzle_word[1] == guess_word[2]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '/') elif puzzle_word[2] == guess_word[2]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '/') elif puzzle_word[3] == guess_word[2]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '/') elif puzzle_word[4] == guess_word[2]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '/') if guess_word[3] in puzzle_word and guess_word[3] != '-': wrong_position = replace_kth_letter_in_str(wrong_position, 3, guess_word[3]) if puzzle_word[0] == guess_word[3]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '/') elif puzzle_word[1] == guess_word[3]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '/') elif puzzle_word[2] == guess_word[3]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '/') elif puzzle_word[3] == guess_word[3]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '/') elif puzzle_word[4] == guess_word[3]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '/') if guess_word[4] in puzzle_word and guess_word[4] != '-': wrong_position = replace_kth_letter_in_str(wrong_position, 4, guess_word[4]) if puzzle_word[0] == guess_word[4]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '/') elif puzzle_word[1] == guess_word[4]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '/') elif puzzle_word[2] == guess_word[4]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '/') elif puzzle_word[3] == guess_word[4]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '/') elif puzzle_word[4] == guess_word[4]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '/') return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == 'green': if text[0] != '?' and text[0] != '*': colored_text = colored_text + white_on_green + text[0] + normal else: colored_text = colored_text + text[0] if text[1] != '?' and text[1] != '*': colored_text = colored_text + white_on_green + text[1] + normal else: colored_text = colored_text + text[1] if text[2] != '?' and text[2] != '*': colored_text = colored_text + white_on_green + text[2] + normal else: colored_text = colored_text + text[2] if text[3] != '?' and text[3] != '*': colored_text = colored_text + white_on_green + text[3] + normal else: colored_text = colored_text + text[3] if text[4] != '?' and text[4] != '*': colored_text = colored_text + white_on_green + text[4] + normal else: colored_text = colored_text + text[4] if color == 'yellow': if text[0] != '?' and text[0] != '*': colored_text = colored_text + white_on_yellow + text[0] + normal else: colored_text = colored_text + text[0] if text[1] != '?' and text[1] != '*': colored_text = colored_text + white_on_yellow + text[1] + normal else: colored_text = colored_text + text[1] if text[2] != '?' and text[2] != '*': colored_text = colored_text + white_on_yellow + text[2] + normal else: colored_text = colored_text + text[2] if text[3] != '?' and text[3] != '*': colored_text = colored_text + white_on_yellow + text[3] + normal else: colored_text = colored_text + text[3] if text[4] != '?' and text[4] != '*': colored_text = colored_text + white_on_yellow + text[4] + normal else: colored_text = colored_text + text[4] return colored_text# 6430401521 sim = 73.52% import random import string def position_in_word(ch, word): if ch in word[0]: position = 0 elif ch in word[1]: position = 1 elif ch in word[2]: position = 2 elif ch in word[3]: position = 3 elif ch in word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' if guess_word[0] == puzzle_word[0]: correct = replace_kth_letter_in_str(correct, 0, guess_word[0]) guess_word = replace_kth_letter_in_str(guess_word, 0, '-') puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') if guess_word[1] == puzzle_word[1]: correct = replace_kth_letter_in_str(correct, 1, guess_word[1]) guess_word = replace_kth_letter_in_str(guess_word, 1, '-') puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') if guess_word[2] == puzzle_word[2]: correct = replace_kth_letter_in_str(correct, 2, guess_word[2]) guess_word = replace_kth_letter_in_str(guess_word, 2, '-') puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') if guess_word[3] == puzzle_word[3]: correct = replace_kth_letter_in_str(correct, 3, guess_word[3]) guess_word = replace_kth_letter_in_str(guess_word, 3, '-') puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') if guess_word[4] == puzzle_word[4]: correct = replace_kth_letter_in_str(correct, 4, guess_word[4]) guess_word = replace_kth_letter_in_str(guess_word, 4, '-') puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') new_guess_word = guess_word new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): replaced = original_str[:k] + ch + original_str[k+1:] return replaced def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] != '-' and guess_word[0] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 0, guess_word[0]) if guess_word[0] == puzzle_word[1]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') elif guess_word[0] == puzzle_word[2]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') elif guess_word[0] == puzzle_word[3]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') elif guess_word[0] == puzzle_word[4]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') if guess_word[1] != '-' and guess_word[1] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 1, guess_word[1]) if guess_word[1] == puzzle_word[0]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') elif guess_word[1] == puzzle_word[2]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') elif guess_word[1] == puzzle_word[3]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') elif guess_word[1] == puzzle_word[4]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') if guess_word[2] != '-' and guess_word[2] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 2, guess_word[2]) if guess_word[2] == puzzle_word[0]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') elif guess_word[2] == puzzle_word[1]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') elif guess_word[2] == puzzle_word[3]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') elif guess_word[2] == puzzle_word[4]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') if guess_word[3] != '-' and guess_word[3] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 3, guess_word[3]) if guess_word[3] == puzzle_word[0]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') elif guess_word[3] == puzzle_word[1]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') elif guess_word[3] == puzzle_word[2]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') elif guess_word[3] == puzzle_word[4]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') if guess_word[4] != '-' and guess_word[4] in puzzle_word: wrong_position = replace_kth_letter_in_str(wrong_position, 4, guess_word[4]) if guess_word[4] == puzzle_word[0]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') elif guess_word[4] == puzzle_word[1]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') elif guess_word[4] == puzzle_word[2]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') elif guess_word[4] == puzzle_word[3]: puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if 'A' <= text[0] <= 'Z' and color == 'green': ch1 = white_on_green + text[0] + normal elif 'A' <= text[0] <= 'Z' and color == 'yellow': ch1 = white_on_yellow + text[0] + normal else: ch1 = text[0] if 'A' <= text[1] <= 'Z' and color == 'green': ch2 = white_on_green + text[1] + normal elif 'A' <= text[1] <= 'Z' and color == 'yellow': ch2 = white_on_yellow + text[1] + normal else: ch2 = text[1] if 'A' <= text[2] <= 'Z' and color == 'green': ch3 = white_on_green + text[2] + normal elif 'A' <= text[2] <= 'Z' and color == 'yellow': ch3 = white_on_yellow + text[2] + normal else: ch3 = text[2] if 'A' <= text[3] <= 'Z' and color == 'green': ch4 = white_on_green + text[3] + normal elif 'A' <= text[3] <= 'Z' and color == 'yellow': ch4 = white_on_yellow + text[3] + normal else: ch4 = text[3] if 'A' <= text[4] <= 'Z' and color == 'green': ch5 = white_on_green + text[4] + normal elif 'A' <= text[4] <= 'Z' and color == 'yellow': ch5 = white_on_yellow + text[4] + normal else: ch5 = text[4] text = ch1 + ch2 + ch3 + ch4 + ch5 colored_text = text return colored_text# 6432069221 sim = 71.92% import random import string def position_in_word(ch, word): if ch in word: if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: correct = guess_word[0] + correct[1:] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 0, '-') if guess_word[1] == puzzle_word[1]: correct = correct[:1] + guess_word[1] + correct[2:] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 1, '-') if guess_word[2] == puzzle_word[2]: correct = correct[:2] + guess_word[2] + correct[3:] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 2, '-') if guess_word[3] == puzzle_word[3]: correct = correct[:3] + guess_word[3] + correct[4:] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 3, '-') if guess_word[4] == puzzle_word[4]: correct = correct[:4] + guess_word[4] + correct[5:] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, 4, '-') return correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): k = int(k) if k == 0: original_str = ch + original_str[k+1:] else: original_str = original_str[:k] + ch + original_str[k+1:] return original_str def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if (guess_word[0] in puzzle_word) and (guess_word[0] != puzzle_word[0]): n = 0 wrong_position = replace_kth_letter_in_str(wrong_position, n, guess_word[n]) if puzzle_word[0] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') elif puzzle_word[1] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') elif puzzle_word[2] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') elif puzzle_word[3] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') elif puzzle_word[4] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') if (guess_word[1] in puzzle_word) and (guess_word[1] != puzzle_word[1]): n = 1 wrong_position = replace_kth_letter_in_str(wrong_position, n, guess_word[n]) if puzzle_word[0] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') elif puzzle_word[1] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') elif puzzle_word[2] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') elif puzzle_word[3] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') elif puzzle_word[4] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') if (guess_word[2] in puzzle_word) and (guess_word[2] != puzzle_word[2]): n = 2 wrong_position = replace_kth_letter_in_str(wrong_position, n, guess_word[n]) if puzzle_word[0] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') elif puzzle_word[1] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') elif puzzle_word[2] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') elif puzzle_word[3] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') elif puzzle_word[4] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') if (guess_word[3] in puzzle_word) and (guess_word[3] != puzzle_word[3]): n = 3 wrong_position = replace_kth_letter_in_str(wrong_position, n, guess_word[n]) if puzzle_word[0] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') elif puzzle_word[1] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') elif puzzle_word[2] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') elif puzzle_word[3] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') elif puzzle_word[4] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') if (guess_word[4] in puzzle_word) and (guess_word[4] != puzzle_word[4]): n = 4 wrong_position = replace_kth_letter_in_str(wrong_position, n, guess_word[n]) if puzzle_word[0] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 0, '-') elif puzzle_word[1] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 1, '-') elif puzzle_word[2] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 2, '-') elif puzzle_word[3] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 3, '-') elif puzzle_word[4] == guess_word[n] : puzzle_word = replace_kth_letter_in_str(puzzle_word, 4, '-') return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' x0 = '' x1 = '' x2 = '' x3 = '' x4 = '' if text[0] != '?' and text[0] != '*' and text[0] != '?' : if color == 'green' : x0 = white_on_green + text[0] + normal elif color == 'yellow' : x0 = white_on_yellow + text[0] + normal else : x0 = text[0] if text[1] != '?' and text[1] != '*' and text[1] != '?' : if color == 'green' : x1 = white_on_green + text[1] + normal elif color == 'yellow' : x1 = white_on_yellow + text[1] + normal else : x1 = text[1] if text[2] != '?' and text[2] != '*' and text[2] != '?' : if color == 'green' : x2 = white_on_green + text[2] + normal elif color == 'yellow' : x2 = white_on_yellow + text[2] + normal else : x2 = text[2] if text[3] != '?' and text[3] != '*' and text[3] != '?' : if color == 'green' : x3 = white_on_green + text[3] + normal elif color == 'yellow' : x3 = white_on_yellow + text[3] + normal else : x3 = text[3] if text[4] != '?' and text[4] != '*' and text[4] != '?' : if color == 'green' : x4 = white_on_green + text[4] + normal elif color == 'yellow' : x4 = white_on_yellow + text[4] + normal else : x4 = text[4] colored_text = x0 + x1 + x2 + x3 + x4 return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #18(4)

# 6430417621 sim = 72.66% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_puzzle_word = puzzle_word new_guess_word = guess_word if guess_word[0]== puzzle_word[0]: correct = guess_word[0]+correct[1:] new_guess_word = '-' + guess_word[1:] new_puzzle_word = '-'+new_puzzle_word[1:] if guess_word[1]== puzzle_word[1]: correct = correct[0]+guess_word[1]+correct[2:] new_guess_word = new_guess_word[0]+'-'+ guess_word[2:] new_puzzle_word = new_puzzle_word[0]+'-'+new_puzzle_word[2:] if guess_word[2]== puzzle_word[2]: correct = correct[0:2]+guess_word[2]+correct[3:] new_guess_word = new_guess_word[0:2]+'-'+ guess_word[3:] new_puzzle_word = new_puzzle_word[0:2]+'-'+new_puzzle_word[3:] if guess_word[3]== puzzle_word[3]: correct = correct[0:3]+guess_word[3]+correct[4:] new_guess_word = new_guess_word[0:3]+'-'+ guess_word[4:] new_puzzle_word = new_puzzle_word[0:3]+'-'+new_puzzle_word[4:] if guess_word[4]== puzzle_word[4]: correct = correct[0:4]+guess_word[4] new_guess_word = new_guess_word[0:4]+'-' new_puzzle_word = new_puzzle_word[0:4]+'-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0]!='-': if guess_word[0] in [puzzle_word[1],puzzle_word[2],puzzle_word[3],puzzle_word[4]]: wrong_position = guess_word[0]+wrong_position[1:] if guess_word[1]!='-': if guess_word[1] in [puzzle_word[0],puzzle_word[2],puzzle_word[3],puzzle_word[4]]: wrong_position = wrong_position[0]+guess_word[1]+wrong_position[2:] if guess_word[2]!='-': if guess_word[2] in [puzzle_word[1],puzzle_word[0],puzzle_word[3],puzzle_word[4]]: wrong_position = wrong_position[0:2]+guess_word[2]+wrong_position[3:] if guess_word[3]!='-': if guess_word[3] in [puzzle_word[1],puzzle_word[2],puzzle_word[0],puzzle_word[4]]: wrong_position = wrong_position[0:3]+guess_word[3]+wrong_position[4] if guess_word[4]!='-': if guess_word[4] in [puzzle_word[1],puzzle_word[2],puzzle_word[3],puzzle_word[0]]: wrong_position = wrong_position[0:4]+guess_word[4] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0: original_str=ch+original_str[1:] elif k == 1: original_str=original_str[0]+ch+original_str[2:] elif k == 2: original_str=original_str[0:2]+ch+original_str[3:] elif k == 3: original_str=original_str[0:3]+ch+original_str[4:] elif k == 4: original_str=original_str[0:4]+ch return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text if color == 'green': if text[0]!='?': g0= white_on_green + text[0] + normal else: g0= '?' if text[1]!='?': g1= white_on_green + text[1] + normal else : g1='?' if text[2]!='?': g2= white_on_green + text[2] + normal else : g2='?' if text[3]!='?': g3= white_on_green + text[3] + normal else: g3='?' if text[4]!='?': g4= white_on_green + text[4] + normal else : g4='?' colored_text = g0+g1+g2+g3+g4 elif color == 'yellow': if text[0]!='*': y0= white_on_yellow + text[0] + normal else: y0= '*' if text[1]!='*': y1= white_on_yellow + text[1] + normal else: y1='*' if text[2]!='*': y2= white_on_yellow + text[2] + normal else: y2='*' if text[3]!='*': y3= white_on_yellow + text[3] + normal else: y3='*' if text[4]!='*': y4= white_on_yellow + text[4] + normal else: y4='*' colored_text=y0+y1+y2+y3+y4 text = colored_text return colored_text# 6430427921 sim = 72.66% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = position + 1 else: if ch == word[1]: position = position + 2 else: if ch == word[2]: position = position + 3 else: if ch == word[3]: position = position + 4 else: if ch == word[4]: position = position + 5 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_puzzle_word = puzzle_word new_guess_word = guess_word if guess_word[0] == puzzle_word[0]: new_guess_word = '-' + new_guess_word[1:] correct = guess_word[0] + correct[1:] new_puzzle_word = '-' + new_puzzle_word[1:] if guess_word[1] == puzzle_word[1]: new_guess_word = new_guess_word[0] + '-' + new_guess_word[2:] correct = correct[0] + guess_word[1] + correct[2:] new_puzzle_word = new_puzzle_word[0] + '-' + new_puzzle_word[2:] if guess_word[2] == puzzle_word[2]: new_guess_word = new_guess_word[0:2] + '-' + new_guess_word[3:] correct = correct[0:2] + guess_word[2] + correct[3:] new_puzzle_word = new_puzzle_word[0:2] + '-' + new_puzzle_word[3:] if guess_word[3] == puzzle_word[3]: new_guess_word = new_guess_word[0:3] + '-' + new_guess_word[4:] correct = correct[0:3] + guess_word[3] + correct[4:] new_puzzle_word = new_puzzle_word[0:3] + '-' + new_puzzle_word[4:] if guess_word[4] == puzzle_word[4]: new_guess_word = new_guess_word[0:4] + '-' correct = correct[0:4] + guess_word[4] new_puzzle_word = new_puzzle_word[0:4] + '-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if guess_word[0] in puzzle_word: if guess_word[0] != puzzle_word[0]: wrong_position = guess_word[0] + wrong_position[1:] if guess_word[1] in puzzle_word: if guess_word[1] != puzzle_word[1]: wrong_position = wrong_position[:1] + guess_word[1] + wrong_position[2:] if guess_word[2] in puzzle_word: if guess_word[2] != puzzle_word[2]: wrong_position = wrong_position[:2] + guess_word[2] + wrong_position[3:] if guess_word[3] in puzzle_word: if guess_word[3] != puzzle_word[3]: wrong_position = wrong_position[:3] + guess_word[3] + wrong_position[4:] if guess_word[4] in puzzle_word: if guess_word[4] != puzzle_word[4]: wrong_position = wrong_position[:4] + guess_word[4] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if 0 < k < 4: original_str = original_str[:k] + ch + original_str[(k+1):] else: if k == 0: original_str = ch + original_str[1:] else: original_str = original_str[:4] + ch return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == 'green': if text[0] != '?': text1 = white_on_green + text[0] + normal else: text1 = text[0] if text[1] != '?': text2 = white_on_green + text[1] + normal else: text2 = text[1] if text[2] != '?': text3 = white_on_green + text[2] + normal else: text3 = text[2] if text[3] != '?': text4 = white_on_green + text[3] + normal else: text4 = text[3] if text[4] != '?': text5 = white_on_green + text[4] + normal else: text5 = text[4] if color == 'yellow': if text[0] != '*': text1 = white_on_yellow + text[0] + normal else: text1 = text[0] if text[1] != '*': text2 = white_on_yellow + text[1] + normal else: text2 = text[1] if text[2] != '*': text3 = white_on_yellow + text[2] + normal else: text3 = text[2] if text[3] != '*': text4 = white_on_yellow + text[3] + normal else: text4 = text[3] if text[4] != '*': text5 = white_on_yellow + text[4] + normal else: text5 = text[4] colored_text = text1 + text2 + text3 + text4 + text5 return colored_text# 6430452521 sim = 70.88% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' new_guess_word = guess_word new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_guess_word = "-" + guess_word[1:5] correct = puzzle_word[0]+correct[1:5] new_puzzle_word = "-" + puzzle_word[1:5] if guess_word[1] == puzzle_word[1]: new_guess_word = new_guess_word[0]+"-"+guess_word[2:5] correct = correct[0]+puzzle_word[1]+correct[2:5] new_puzzle_word = new_puzzle_word[0]+"-"+puzzle_word[2:5] if guess_word[2] == puzzle_word[2]: new_guess_word = new_guess_word[0:2]+"-"+guess_word[3:5] correct = correct[0:2]+puzzle_word[2]+correct[3:5] new_puzzle_word = new_puzzle_word[0:2]+"-"+puzzle_word[3:5] if guess_word[3] == puzzle_word[3]: new_guess_word = new_guess_word[0:3]+"-"+guess_word[4] correct = correct[0:3]+puzzle_word[3]+correct[4] new_puzzle_word = new_puzzle_word[0:3]+"-"+puzzle_word[4] if guess_word[4] == puzzle_word[4]: new_guess_word = new_guess_word[0:4]+"-" correct = correct[0:4]+puzzle_word[4] new_puzzle_word = new_puzzle_word[0:4]+"-" return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if (guess_word[0] in puzzle_word) and (puzzle_word[0] != guess_word[0]): wrong_position = guess_word[0] + wrong_position[1:5] if (guess_word[1] in puzzle_word) and puzzle_word[1] != guess_word[1]: wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:5] if (guess_word[2] in puzzle_word) and puzzle_word[2] != guess_word[2]: wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:5] if (guess_word[3] in puzzle_word) and puzzle_word[3] != guess_word[3]: wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4] if (guess_word[4] in puzzle_word) and puzzle_word[4] != guess_word[4]: wrong_position = wrong_position[0:4] + guess_word[4] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): original_str = original_str[0:k] + ch + original_str[k+1:5] return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' ABC26 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] if color == 'green': if text[0] in ABC26: new_text = white_on_green + text[0] + normal else: new_text = text[0] if text[1] in ABC26: new_text = new_text + white_on_green + text[1] + normal else: new_text = new_text + text[1] if text[2] in ABC26: new_text = new_text + white_on_green + text[2] + normal else: new_text = new_text + text[2] if text[3] in ABC26: new_text = new_text + white_on_green + text[3] + normal else: new_text = new_text + text[3] if text[4] in ABC26: new_text = new_text + white_on_green + text[4] + normal else: new_text = new_text + text[4] elif color == 'yellow': if text[0] in ABC26: new_text = white_on_yellow + text[0] + normal else: new_text = text[0] if text[1] in ABC26: new_text = new_text + white_on_yellow + text[1] + normal else: new_text = new_text + text[1] if text[2] in ABC26: new_text = new_text + white_on_yellow + text[2] + normal else: new_text = new_text + text[2] if text[3] in ABC26: new_text = new_text + white_on_yellow + text[3] + normal else: new_text = new_text + text[3] if text[4] in ABC26: new_text = new_text + white_on_yellow + text[4] + normal else: new_text = new_text + text[4] colored_text = new_text return colored_text# 6430341521 sim = 70.01% import random import string def position_in_word(ch, word): position = -1 if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word correct = '?????' if new_guess_word[0] == new_puzzle_word[0] : new_guess_word = '-' + guess_word[1:] correct = puzzle_word[0] + '????' new_puzzle_word = '-' + puzzle_word[1:] if new_guess_word[1] == new_puzzle_word[1] : new_guess_word = new_guess_word[0] + '-' + new_guess_word[2:] correct = correct[0] + puzzle_word[1] + correct[2:] new_puzzle_word = new_puzzle_word[0] + '-' + new_puzzle_word[2:] if new_guess_word[2] == new_puzzle_word[2] : new_guess_word = new_guess_word[0:2] + '-' + new_guess_word[3:] correct = correct[0:2] + puzzle_word[2] + correct[3:] new_puzzle_word = new_puzzle_word[0:2] + '-' + new_puzzle_word[3:] if new_guess_word[3] == new_puzzle_word[3] : new_guess_word = new_guess_word[0:3] + '-' + new_guess_word[4:] correct = correct[0:3] + puzzle_word[3] + correct[4:] new_puzzle_word = new_puzzle_word[0:3] + '-' + new_puzzle_word[4:] if new_guess_word[4] == new_puzzle_word[4] : new_guess_word = new_guess_word[0:4] + '-' correct = correct[0:4] + puzzle_word[4] new_puzzle_word = new_puzzle_word[0:4] + '-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' wrong_position = '*****' if guess_word[0] in puzzle_word[1:] and guess_word[0] != '-' : wrong_position = guess_word[0] + '****' if (guess_word[1] in puzzle_word[0] and guess_word[1] != '-') or (guess_word[1] in puzzle_word[2:] and guess_word[1] != '-') : wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2:] if (guess_word[2] in puzzle_word[0:2] and guess_word[2] != '-') or (guess_word[2] in puzzle_word[3:] and guess_word[2] != '-') : wrong_position = wrong_position[0:2] + guess_word[2] + wrong_position[3:] if (guess_word[3] in puzzle_word[0:3] and guess_word[3] != '-') or (guess_word[3] in puzzle_word[4:] and guess_word[3] != '-') : wrong_position = wrong_position[0:3] + guess_word[3] + wrong_position[4:] if guess_word[4] in puzzle_word[0:4] and guess_word[4] != '-' : wrong_position = wrong_position[0:4] + guess_word[4] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k!= 4 : replace = original_str[:k] + ch + original_str[k+1:] else : replace = original_str[:k] + ch return replace def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text ch1 = text[0] ch2 = text[1] ch3 = text[2] ch4 = text[3] ch5 = text[4] if color == 'green' : if text[0] != '?' : ch1 = white_on_green + text[0] + normal if text[1] != '?' : ch2 = white_on_green + text[1] + normal if text[2] != '?' : ch3 = white_on_green + text[2] + normal if text[3] != '?' : ch4 = white_on_green + text[3] + normal if text[4] != '?' : ch5 = white_on_green + text[4] + normal colored_text = ch1 + ch2 + ch3 + ch4 + ch5 if color == 'yellow' : if text[0] != '*' : ch1 = white_on_yellow + text[0] + normal if text[1] != '*' : ch2 = white_on_yellow + text[1] + normal if text[2] != '*' : ch3 = white_on_yellow + text[2] + normal if text[3] != '*' : ch4 = white_on_yellow + text[3] + normal if text[4] != '*' : ch5 = white_on_yellow + text[4] + normal colored_text = ch1 + ch2 + ch3 + ch4 + ch5 return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #19(2)

# 6430366221 sim = 71.73% import random import string def position_in_word(ch, word): position = -1 if ch in word[0] : position = 0 elif ch in word[1] : position = 1 elif ch in word[2] : position = 2 elif ch in word[3] : position = 3 elif ch in word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word x = '' y = '' z = '' if guess_word[0] == puzzle_word[0] : x += '-' y += guess_word[0] z += '-' else : x += guess_word[0] y += '?' z += puzzle_word[0] if guess_word[1] == puzzle_word[1] : x += '-' y += guess_word[1] z += '-' else : x += guess_word[1] y += '?' z += puzzle_word[1] if guess_word[2] == puzzle_word[2] : x += '-' y += guess_word[2] z += '-' else : x += guess_word[2] y += '?' z += puzzle_word[2] if guess_word[3] == puzzle_word[3] : x += '-' y += guess_word[3] z += '-' else : x += guess_word[3] y += '?' z += puzzle_word[3] if guess_word[4] == puzzle_word[4] : x += '-' y += guess_word[4] z += '-' else : x += guess_word[4] y += '?' z += puzzle_word[4] new_guess_word = x correct = y new_puzzle_word = z return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != '-' : wrong_position += guess_word[0] a = puzzle_word[:position_in_word(guess_word[0], puzzle_word)] + puzzle_word[position_in_word(guess_word[0], puzzle_word)+1:] else : wrong_position += '*' a = puzzle_word if guess_word[1] in a and guess_word[1] != '-' : wrong_position += guess_word[1] a = a[:position_in_word(guess_word[1], a)] + a[position_in_word(guess_word[1], a)+1:] else : wrong_position += '*' if guess_word[2] in a and guess_word[2] != '-' : wrong_position += guess_word[2] a = a = a[:position_in_word(guess_word[2], a)] + a[position_in_word(guess_word[2], a)+1:] else : wrong_position += '*' if guess_word[3] in a and guess_word[3] != '-' : wrong_position += guess_word[3] a = a[:position_in_word(guess_word[3], a)] + a[position_in_word(guess_word[3], a)+1:] else : wrong_position += '*' if guess_word[4] in a and guess_word[4] != '-' : wrong_position += guess_word[4] else : wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): x = '' x += original_str[0:k] + ch + original_str[k+1:] return x def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text colored_text = '' g = white_on_green y = white_on_yellow x = text if color == 'green' : if x[0] == '?' : colored_text += '?' else : colored_text += g + x[0] + normal if x[1] == '?' : colored_text += '?' else : colored_text += g + x[1] + normal if x[2] == '?' : colored_text += '?' else : colored_text += g + x[2] + normal if x[3] == '?' : colored_text += '?' else : colored_text += g + x[3] + normal if x[4] == '?' : colored_text += '?' else : colored_text += g + x[4] + normal elif color == 'yellow' : if x[0] == '*' : colored_text += '*' else : colored_text += y + x[0] + normal if x[1] == '*' : colored_text += '*' else : colored_text += y + x[1] + normal if x[2] == '*' : colored_text += '*' else : colored_text += y + x[2] + normal if x[3] == '*' : colored_text += '*' else : colored_text += y + x[3] + normal if x[4] == '*' : colored_text += '*' else : colored_text += y + x[4] + normal return colored_text# 6430404421 sim = 71.73% import random import string def position_in_word(ch, word): if ch == word[0]: return 0 if ch == word[1]: return 1 if ch == word[2]: return 2 if ch == word[3]: return 3 if ch == word[4]: return 4 return -1 def check_correct_position(puzzle_word, guess_word): new_guess_word = "" correct = "" new_puzzle_word = "" if puzzle_word[0] == guess_word[0]: new_guess_word+="-"; correct += guess_word[0]; new_puzzle_word += "-" else: new_guess_word+=guess_word[0]; correct+= "?"; new_puzzle_word += puzzle_word[0] if puzzle_word[1] == guess_word[1]: new_guess_word+="-"; correct += guess_word[1]; new_puzzle_word += "-" else: new_guess_word+=guess_word[1]; correct+= "?"; new_puzzle_word += puzzle_word[1] if puzzle_word[2] == guess_word[2]: new_guess_word+="-"; correct += guess_word[2]; new_puzzle_word += "-" else: new_guess_word+=guess_word[2]; correct+= "?"; new_puzzle_word += puzzle_word[2] if puzzle_word[3] == guess_word[3]: new_guess_word+="-"; correct += guess_word[3]; new_puzzle_word += "-" else: new_guess_word+=guess_word[3]; correct+= "?"; new_puzzle_word += puzzle_word[3] if puzzle_word[4] == guess_word[4]: new_guess_word+="-"; correct += guess_word[4]; new_puzzle_word += "-" else: new_guess_word+=guess_word[4]; correct+= "?"; new_puzzle_word += puzzle_word[4] return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): a = "" if guess_word[0] in puzzle_word: a += guess_word[0] b = position_in_word(guess_word[0], puzzle_word) puzzle_word = puzzle_word[:b]+"-"+puzzle_word[b+1:] else: a += "*" if guess_word[1] in puzzle_word: a += guess_word[1] b = position_in_word(guess_word[1], puzzle_word) puzzle_word = puzzle_word[:b]+"-"+puzzle_word[b+1:] else: a += "*" if guess_word[2] in puzzle_word: a += guess_word[2] b = position_in_word(guess_word[2], puzzle_word) puzzle_word = puzzle_word[:b]+"-"+puzzle_word[b+1:] else: a += "*" if guess_word[3] in puzzle_word: a += guess_word[3] b = position_in_word(guess_word[3], puzzle_word) puzzle_word = puzzle_word[:b]+"-"+puzzle_word[b+1:] else: a += "*" if guess_word[4] in puzzle_word: a += guess_word[4] b = position_in_word(guess_word[4], puzzle_word) puzzle_word = puzzle_word[:b]+"-"+puzzle_word[b+1:] else: a += "*" return a def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k]+ch+original_str[k+1:] def color_text(text, color): a = "" if color == "green": if text[0] == "?": a += "?" else: a += '\033[37;42m'+text[0]+'\033[0;0m' if text[1] == "?": a += "?" else: a += '\033[37;42m'+text[1]+'\033[0;0m' if text[2] == "?": a += "?" else: a += '\033[37;42m'+text[2]+'\033[0;0m' if text[3] == "?": a += "?" else: a += '\033[37;42m'+text[3]+'\033[0;0m' if text[4] == "?": a += "?" else: a += '\033[37;42m'+text[4]+'\033[0;0m' elif color == "yellow": a = "" if text[0] == "*": a += "*" else: a += '\033[34;43m'+text[0]+'\033[0;0m' if text[1] == "*": a += "*" else: a += '\033[34;43m'+text[1]+'\033[0;0m' if text[2] == "*": a += "*" else: a += '\033[34;43m'+text[2]+'\033[0;0m' if text[3] == "*": a += "*" else: a += '\033[34;43m'+text[3]+'\033[0;0m' if text[4] == "*": a += "*" else: a += '\033[34;43m'+text[4]+'\033[0;0m' return a

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #20(2)

# 6430283821 sim = 71.7% import random import string def position_in_word(ch, word): if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if guess_word[0] == puzzle_word[0]: new_guess_word = '-' + new_guess_word[1::] correct = puzzle_word[0] + correct[1::] new_puzzle_word = '-' + new_puzzle_word[1::] if guess_word[1] == puzzle_word[1]: new_guess_word = new_guess_word[0] + '-' + new_guess_word[2::] correct = correct[0] + puzzle_word[1] + correct[2::] new_puzzle_word = new_puzzle_word[0] + '-' + new_puzzle_word[2::] if guess_word[2] == puzzle_word[2]: new_guess_word = new_guess_word[:2:] + '-' + new_guess_word[3::] correct = correct[:2:] + puzzle_word[2] + correct[3::] new_puzzle_word = new_puzzle_word[:2:] + '-' + new_puzzle_word[3::] if guess_word[3] == puzzle_word[3]: new_guess_word = new_guess_word[:3:] + '-' + new_guess_word[4::] correct = correct[:3:] + puzzle_word[3] + correct[4::] new_puzzle_word = new_puzzle_word[:3:] + '-' + new_puzzle_word[4::] if guess_word[4] == puzzle_word[4]: new_guess_word = new_guess_word[:4:] + '-' correct = correct[:4:] + puzzle_word[4] new_puzzle_word = new_puzzle_word[:4:] + '-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if (guess_word[0] in puzzle_word) and (guess_word[0] != puzzle_word[0]): wrong_position = guess_word[0] + wrong_position[1::] pos = position_in_word(guess_word[0], puzzle_word) if pos != -1: puzzle_word = puzzle_word[:pos:] + '-' + puzzle_word[pos+1::] if (guess_word[1] in puzzle_word) and (guess_word[1] != puzzle_word[1]): wrong_position = wrong_position[0] + guess_word[1] + wrong_position[2::] pos = position_in_word(guess_word[1], puzzle_word) if pos != -1: puzzle_word = puzzle_word[:pos:] + '-' + puzzle_word[pos+1::] if (guess_word[2] in puzzle_word) and (guess_word[2] != puzzle_word[2]): wrong_position = wrong_position[:2:] + guess_word[2] + wrong_position[3::] pos = position_in_word(guess_word[2], puzzle_word) if pos != -1: puzzle_word = puzzle_word[:pos:] + '-' + puzzle_word[pos+1::] if (guess_word[3] in puzzle_word) and (guess_word[3] != puzzle_word[3]): wrong_position = wrong_position[:3:] + guess_word[3] + wrong_position[4::] pos = position_in_word(guess_word[3], puzzle_word) if pos != -1: puzzle_word = puzzle_word[:pos:] + '-' + puzzle_word[pos+1::] if (guess_word[4] in puzzle_word) and (guess_word[4] != puzzle_word[4]): wrong_position = wrong_position[:4:] + guess_word[4] pos = position_in_word(guess_word[4], puzzle_word) if pos != -1: puzzle_word = puzzle_word[:pos:] + '-' + puzzle_word[pos+1::] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): replaced_str = original_str[0:k:] + ch + original_str[k+1::] return replaced_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' ch0 = text[0] ch1 = text[1] ch2 = text[2] ch3 = text[3] ch4 = text[4] if color == 'yellow': if ch0 != '*': ch0 = white_on_yellow + text[0] + normal if ch1 != '*': ch1 = white_on_yellow + text[1] + normal if ch2 != '*': ch2 = white_on_yellow + text[2] + normal if ch3 != '*': ch3 = white_on_yellow + text[3] + normal if ch4 != '*': ch4 = white_on_yellow + text[4] + normal if color == 'green': if ch0 != '?': ch0 = white_on_green + text[0] + normal if ch1 != '?': ch1 = white_on_green + text[1] + normal if ch2 != '?': ch2 = white_on_green + text[2] + normal if ch3 != '?': ch3 = white_on_green + text[3] + normal if ch4 != '?': ch4 = white_on_green + text[4] + normal colored_text = ch0+ch1+ch2+ch3+ch4 return colored_text# 6432020421 sim = 71.7% import random import string def position_in_word(ch, word): position = -1 if(word[0]==ch): position = 0 elif(word[1]==ch): position = 1 elif(word[2]==ch): position = 2 elif(word[3]==ch): position = 3 elif(word[4]==ch): position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '?????' new_puzzle_word = puzzle_word if(puzzle_word[0]==guess_word[0]): new_guess_word="-"+new_guess_word[1:] correct=puzzle_word[0]+correct[1:] new_puzzle_word="-"+puzzle_word[1:] if(puzzle_word[1]==guess_word[1]): new_guess_word=new_guess_word[:1]+"-"+new_guess_word[2:] correct=correct[0]+puzzle_word[1]+correct[1:] new_puzzle_word=new_puzzle_word[:1]+"-"+new_puzzle_word[2:] if(puzzle_word[2]==guess_word[2]): new_guess_word=new_guess_word[:2]+"-"+new_guess_word[3:] correct=correct[:2]+puzzle_word[2]+correct[3:] new_puzzle_word=new_puzzle_word[:2]+"-"+new_puzzle_word[3:] if(puzzle_word[3]==guess_word[3]): new_guess_word=new_guess_word[:3]+"-"+new_guess_word[4:] correct=correct[:3]+puzzle_word[3]+correct[4:] new_puzzle_word=new_puzzle_word[:3]+"-"+new_puzzle_word[4:] if(puzzle_word[4]==guess_word[4]): new_guess_word=new_guess_word[:4]+"-" correct=correct[:4]+puzzle_word[4] new_puzzle_word=new_puzzle_word[:4]+"-" return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '*****' if(puzzle_word[0]!=guess_word[0] and guess_word[0] in puzzle_word): wrong_position=guess_word[0]+wrong_position[1:] n=position_in_word(guess_word[0],puzzle_word) if(n!=-1): puzzle_word=replace_kth_letter_in_str(puzzle_word,n,"-") print(puzzle_word) if(puzzle_word[1]!=guess_word[1] and guess_word[1] in puzzle_word): wrong_position=wrong_position[0]+guess_word[1]+wrong_position[2:] n=position_in_word(guess_word[1],puzzle_word) if(n!=-1): puzzle_word=replace_kth_letter_in_str(puzzle_word,n,"-") print(puzzle_word) if(puzzle_word[2]!=guess_word[2] and guess_word[2] in puzzle_word): wrong_position=wrong_position[:2]+guess_word[2]+wrong_position[3:] n=position_in_word(guess_word[2],puzzle_word) if(n!=-1): puzzle_word=replace_kth_letter_in_str(puzzle_word,n,"-") print(puzzle_word) if(puzzle_word[3]!=guess_word[3] and guess_word[3] in puzzle_word): wrong_position=wrong_position[:3]+guess_word[3]+wrong_position[4] n=position_in_word(guess_word[3],puzzle_word) if(n!=-1): puzzle_word=replace_kth_letter_in_str(puzzle_word,n,"-") print(puzzle_word) if(puzzle_word[4]!=guess_word[4] and guess_word[4] in puzzle_word): wrong_position=wrong_position[:4]+guess_word[4] n=position_in_word(guess_word[4],puzzle_word) if(n!=-1): puzzle_word=replace_kth_letter_in_str(puzzle_word,n,"-") print(puzzle_word) return wrong_position def replace_kth_letter_in_str(original_str, k, ch): original_str=original_str[:k]+ch+original_str[k+1:] return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' c1=text[0] c2=text[1] c3=text[2] c4=text[3] c5=text[4] if(color=="green"): if(text[0] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"): c1=white_on_green+text[0]+normal if(text[1] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"): c2=white_on_green+text[1]+normal if(text[2] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"): c3=white_on_green+text[2]+normal if(text[3] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"): c4=white_on_green+text[3]+normal if(text[4] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"): c5=white_on_green+text[4]+normal if(color=="yellow"): if(text[0] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"): c1=white_on_yellow+text[0]+normal if(text[1] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"): c2=white_on_yellow+text[1]+normal if(text[2] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"): c3=white_on_yellow+text[2]+normal if(text[3] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"): c4=white_on_yellow+text[3]+normal if(text[4] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"): c5=white_on_yellow+text[4]+normal colored_text=c1+c2+c3+c4+c5 return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #21(2)

# 6430201321 sim = 71.45% import random import string def position_in_word(ch, word): if ch in word: if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = ['?']*5 guess_word = list(guess_word) puzzle_word = list(puzzle_word) if guess_word[0] == puzzle_word[0]: correct[0] = guess_word[0] guess_word[0] = '-' puzzle_word[0] = '-' if guess_word[1] == puzzle_word[1]: correct[1] = guess_word[1] guess_word[1] = '-' puzzle_word[1] = '-' print('FUCK') if guess_word[2] == puzzle_word[2]: correct[2] = guess_word[2] guess_word[2] = '-' puzzle_word[2] = '-' if guess_word[3] == puzzle_word[3]: correct[3] = guess_word[3] guess_word[3] = '-' puzzle_word[3] = '-' if guess_word[4] == puzzle_word[4]: correct[4] = guess_word[4] guess_word[4] = '-' puzzle_word[4] = '-' new_guess_word = ''.join(guess_word) new_puzzle_word = ''.join(puzzle_word) correct = ''.join(correct) return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = ['*']*5 guess_word = list(guess_word) puzzle_word = list(puzzle_word) if guess_word[0] in puzzle_word: if guess_word[0] != '-': wrong_position[0] = guess_word[0] puzzle_word.remove(guess_word[0]) if guess_word[1] in puzzle_word: if guess_word[1] != '-': wrong_position[1] = guess_word[1] puzzle_word.remove(guess_word[1]) if guess_word[2] in puzzle_word: if guess_word[2] != '-': wrong_position[2] = guess_word[2] puzzle_word.remove(guess_word[2]) if guess_word[3] in puzzle_word: if guess_word[3] != '-': wrong_position[3] = guess_word[3] puzzle_word.remove(guess_word[3]) if guess_word[4] in puzzle_word: if guess_word[4] != '-': wrong_position[4] = guess_word[4] puzzle_word.remove(guess_word[4]) wrong_position = ''.join(wrong_position) return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k:] + ch + original_str[k+1::] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' not_letters = ['*','?'] text = list(text) if text[0] not in not_letters: if color == 'green': text[0] = white_on_green + text[0] + normal elif color == 'yellow': text[0] = white_on_yellow + text[0] + normal if text[1] not in not_letters: if color == 'green': text[1] = white_on_green + text[1] + normal elif color == 'yellow': text[1] = white_on_yellow + text[1] + normal if text[2] not in not_letters: if color == 'green': text[2] = white_on_green + text[2] + normal elif color == 'yellow': text[2] = white_on_yellow + text[2] + normal if text[3] not in not_letters: if color == 'green': text[3] = white_on_green + text[3] + normal elif color == 'yellow': text[3] = white_on_yellow + text[3] + normal if text[4] not in not_letters: if color == 'green': text[4] = white_on_green + text[4] + normal elif color == 'yellow': text[4] = white_on_yellow + text[4] + normal text = ''.join(text) colored_text = text return colored_text# 6430238621 sim = 71.45% import random import string def position_in_word(ch, word): position = -1 if ch==word[0]: position=0 elif ch==word[1]: position=1 elif ch==word[2]: position=2 elif ch==word[3]: position=3 elif ch==word[4]: position=4 return position def check_correct_position(puzzle_word, guess_word): correct = ['?','?','?','?','?'] new_puzzle_word = [puzzle_word[0],puzzle_word[1],puzzle_word[2],puzzle_word[3],puzzle_word[4]] guess_word = [guess_word[0],guess_word[1],guess_word[2],guess_word[3],guess_word[4]] new_guess_word = guess_word if guess_word[0]==puzzle_word[0]: correct[0] = guess_word[0] new_puzzle_word[0] = '-' new_guess_word[0]='-' if guess_word[1]==puzzle_word[1]: correct[1] = guess_word[1] new_puzzle_word[1] = '-' new_guess_word[1]='-' if guess_word[2]==puzzle_word[2]: correct[2] = guess_word[2] new_puzzle_word[2] = '-' new_guess_word[2]='-' if guess_word[3]==puzzle_word[3]: correct[3] = guess_word[3] new_puzzle_word[3] = '-' new_guess_word[3]='-' if guess_word[4]==puzzle_word[4]: correct[4] = guess_word[4] new_puzzle_word[4] = '-' new_guess_word[4]='-' correct = ''.join(correct) new_guess_word = ''.join(new_guess_word) new_puzzle_word = ''.join(new_puzzle_word) return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '* * * * *'.split() if guess_word[0] in puzzle_word and (guess_word[0] != puzzle_word[0]) and puzzle_word[0]!='-' : wrong_position[0]=guess_word[0] if guess_word[1] in puzzle_word and (guess_word[1] != puzzle_word[1]) and puzzle_word[1]!='-' : wrong_position[1]=guess_word[1] if guess_word[2] in puzzle_word and (guess_word[2] != puzzle_word[2]) and puzzle_word[2]!='-' : wrong_position[2]=guess_word[2] if guess_word[3] in puzzle_word and (guess_word[3] != puzzle_word[3]) and puzzle_word[3]!='-' : wrong_position[3]=guess_word[3] if guess_word[4] in puzzle_word and (guess_word[4] != puzzle_word[4]) and puzzle_word[4]!='-' : wrong_position[4]=guess_word[4] wrong_position = ''.join(wrong_position) return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[:int(k)] + ch + original_str[int(k)+1:] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' text = [text[0],text[1],text[2],text[3],text[4]] if text[0] != '?' and text[0] != '*': if color == 'green': text[0] = white_on_green + text[0] + normal elif color == 'yellow': text[0] = white_on_yellow + text[0] + normal if text[1] != '?' and text[1] != '*': if color == 'green': text[1] = white_on_green + text[1] + normal elif color == 'yellow': text[1] = white_on_yellow + text[1] + normal if text[2] != '?' and text[2] != '*': if color == 'green': text[2] = white_on_green + text[2] + normal elif color == 'yellow': text[2] = white_on_yellow + text[2] + normal if text[3] != '?' and text[3] != '*': if color == 'green': text[3] = white_on_green + text[3] + normal elif color == 'yellow': text[3] = white_on_yellow + text[3] + normal if text[4] != '?' and text[4] != '*': if color == 'green': text[4] = white_on_green + text[4] + normal elif color == 'yellow': text[4] = white_on_yellow + text[4] + normal text=''.join(text) colored_text = text return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #22(2)

# 6430375921 sim = 71.39% import random import string def position_in_word(ch, word): if ch in list(word)[0]: position = 0 else: if ch in list(word)[1]: position = 1 else: if ch in list(word)[2]: position = 2 else: if ch in list(word)[3]: position = 3 else: if ch in list(word)[4]: position = 4 else: if ch not in list(word): position = -1 else: pass return position def check_correct_position(puzzle_word, guess_word): if guess_word[0] == puzzle_word[0]: new_guess_word0 = "-" correct0 = guess_word[0] new_puzzle_word0 = "-" else: new_guess_word0 = guess_word[0] correct0 = "?" new_puzzle_word0 = puzzle_word[0] if guess_word[1] == puzzle_word[1]: new_guess_word1 = "-" correct1 = guess_word[1] new_puzzle_word1 = "-" else: new_guess_word1 = guess_word[1] correct1 = "?" new_puzzle_word1 = puzzle_word[1] if guess_word[2] == puzzle_word[2]: new_guess_word2 = "-" correct2 = guess_word[2] new_puzzle_word2 = "-" else: new_guess_word2 = guess_word[2] correct2 = "?" new_puzzle_word2 = puzzle_word[2] if guess_word[3] == puzzle_word[3]: new_guess_word3 = "-" correct3 = guess_word[3] new_puzzle_word3 = "-" else: new_guess_word3 = guess_word[3] correct3 = "?" new_puzzle_word3 = puzzle_word[3] if guess_word[4] == puzzle_word[4]: new_guess_word4 = "-" correct4 = guess_word[4] new_puzzle_word4 = "-" else: new_guess_word4 = guess_word[4] correct4 = "?" new_puzzle_word4 = puzzle_word[4] new_guess_word = new_guess_word0 + new_guess_word1 + new_guess_word2 + new_guess_word3 + new_guess_word4 correct = correct0 + correct1 + correct2 + correct3 + correct4 new_puzzle_word = new_puzzle_word0 + new_puzzle_word1 + new_puzzle_word2 + new_puzzle_word3 + new_puzzle_word4 return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): print(puzzle_word, guess_word) if guess_word[0] in puzzle_word and guess_word[0] != puzzle_word[0]: a = guess_word[0] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), "-") else: a = "*" if guess_word[1] in puzzle_word and guess_word[1] != puzzle_word[1]: b = guess_word[1] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), "-") else: b = "*" if guess_word[2] in puzzle_word and guess_word[2] != puzzle_word[2]: c = guess_word[2] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), "-") else: c = "*" if guess_word[3] in puzzle_word and guess_word[3] != puzzle_word[3]: d = guess_word[3] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), "-") else: d = "*" if guess_word[4] in puzzle_word and guess_word[4] != puzzle_word[4]: e = guess_word[4] puzzle_word = replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), "-") else: e = "*" wrong_position = a+b+c+d+e return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0: origunal_new = (ch + original_str[1:5:1]) else: if k == 1: origunal_new = (original_str[0] + ch + original_str[2:5:1]) else: if k == 2: origunal_new = ( original_str[0] + original_str[1] + ch + original_str[3:5:1]) else: if k == 3: origunal_new = (original_str[0:3:1] + ch + original_str[4]) else: if k == 4: origunal_new = (original_str[0:4:1] + ch ) else: pass return origunal_new def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == "green": if text[0] != '?': a = white_on_green + text[0] + normal else: a = text[0] if text[1] != '?': b = white_on_green + text[1] + normal else: b = text[1] if text[2] != '?': c = white_on_green + text[2] + normal else: c = text[2] if text[3] != '?': d = white_on_green + text[3] + normal else: d = text[3] if text[4] != '?': e = white_on_green + text[4] + normal else: e = text[4] else: if text[0] != '*': a = white_on_yellow + text[0] + normal else: a = text[0] if text[1] != '*': b = white_on_yellow + text[1] + normal else: b = text[1] if text[2] != '*': c = white_on_yellow + text[2] + normal else: c = text[2] if text[3] != '*': d = white_on_yellow + text[3] + normal else: d = text[3] if text[4] != '*': e = white_on_yellow + text[4] + normal else: e = text[4] colored_text = a + b + c + d + e return colored_text# 6432119021 sim = 71.39% import random import string def position_in_word(ch, word): if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): if guess_word[0]==puzzle_word[0]: c0=puzzle_word[0] np0='-' ng0='-' else: c0='?' np0=puzzle_word[0] ng0=guess_word[0] if guess_word[1]==puzzle_word[1]: c1=puzzle_word[1] np1='-' ng1='-' else: c1='?' np1=puzzle_word[1] ng1=guess_word[1] if guess_word[2]==puzzle_word[2]: c2=puzzle_word[2] np2='-' ng2='-' else: c2='?' np2=puzzle_word[2] ng2=guess_word[2] if guess_word[3]==puzzle_word[3]: c3=puzzle_word[3] np3='-' ng3='-' else: c3='?' np3=puzzle_word[3] ng3=guess_word[3] if guess_word[4]==puzzle_word[4]: c4=puzzle_word[4] np4='-' ng4='-' else: c4='?' np4=puzzle_word[4] ng4=guess_word[4] new_puzzle_word = np0+np1+np2+np3+np4 correct = c0+c1+c2+c3+c4 new_guess_word = ng0+ng1+ng2+ng3+ng4 return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): if guess_word[0]!='-' and guess_word[0] in puzzle_word : wp0=guess_word[0] puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[0], puzzle_word), '-') else: wp0='*' if guess_word[1]!='-' and guess_word[1] in puzzle_word : wp1=guess_word[1] puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[1], puzzle_word), '-') else: wp1='*' if guess_word[2]!='-' and guess_word[2] in puzzle_word : wp2=guess_word[2] puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[2], puzzle_word), '-') else: wp2='*' if guess_word[3]!='-' and guess_word[3] in puzzle_word : wp3=guess_word[3] puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[3], puzzle_word), '-') else: wp3='*' if guess_word[4]!='-' and guess_word[4] in puzzle_word : wp4=guess_word[4] puzzle_word=replace_kth_letter_in_str(puzzle_word, position_in_word(guess_word[4], puzzle_word), '-') else: wp4='*' wrong_position=wp0+wp1+wp2+wp3+wp4 return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k==0: replaced=ch+original_str[1::] elif k==1: replaced=original_str[0]+ch+original_str[2::] elif k==2: replaced=original_str[0:2:]+ch+original_str[3::] elif k==3: replaced=original_str[0:3:]+ch+original_str[4] else: replaced=original_str[0:4:]+ch return replaced def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' ch0,ch1,ch2,ch3,ch4=text[0],text[1],text[2],text[3],text[4] if color=='green': c = white_on_green if text[0]!='?': ch0= c + text[0] + normal if text[1]!='?': ch1= c + text[1] + normal if text[2]!='?' : ch2= c + text[2] + normal if text[3]!='?' : ch3=c + text[3] + normal if text[4]!='?' : ch4= c + text[4] + normal elif color=='yellow': c = white_on_yellow if text[0]!='*': ch0=c+text[0]+normal if text[1]!='*': ch1=c+text[1]+normal if text[2]!='*' : ch2=c+text[2]+normal if text[3]!='*' : ch3=c+text[3]+normal if text[4]!='*' : ch4=c+text[4]+normal colored_text=ch0+ch1+ch2+ch3+ch4 return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #23(2)

# 6430333521 sim = 71.27% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word if puzzle_word[0] == guess_word[0]: correct += puzzle_word[0] else : correct += '?' if puzzle_word[1] == guess_word[1]: correct += puzzle_word[1] else : correct += '?' if puzzle_word[2] == guess_word[2]: correct += puzzle_word[2] else : correct += '?' if puzzle_word[3] == guess_word[3]: correct += puzzle_word[3] else : correct += '?' if puzzle_word[4] == guess_word[4]: correct += puzzle_word[4] else : correct += '?' new_guess_word = '' if puzzle_word[0] == guess_word[0]: new_guess_word += '-' else : new_guess_word += guess_word[0] if puzzle_word[1] == guess_word[1]: new_guess_word += '-' else : new_guess_word += guess_word[1] if puzzle_word[2] == guess_word[2]: new_guess_word += '-' else : new_guess_word += guess_word[2] if puzzle_word[3] == guess_word[3]: new_guess_word += '-' else : new_guess_word += guess_word[3] if puzzle_word[4] == guess_word[4]: new_guess_word += '-' else : new_guess_word += guess_word[4] if puzzle_word[0] == guess_word[0]: new_puzzle_word = '-' + puzzle_word[1:] if puzzle_word[1] == guess_word[1]: new_puzzle_word = puzzle_word[:1] + '-' + puzzle_word[2:] if puzzle_word[2] == guess_word[2]: new_puzzle_word = puzzle_word[:2] + '-' + puzzle_word[3:] if puzzle_word[3] == guess_word[3]: new_puzzle_word = puzzle_word[:3] + '-' + puzzle_word[4] if puzzle_word[4] == guess_word[4]: new_puzzle_word = puzzle_word[:4] + '-' return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != '-': wrong_position += guess_word[0] else: wrong_position += '*' if guess_word[1] in puzzle_word and guess_word[1] != '-': wrong_position += guess_word[1] else: wrong_position += '*' if guess_word[2] in puzzle_word and guess_word[2] != '-': wrong_position += guess_word[2] else: wrong_position += '*' if guess_word[3] in puzzle_word and guess_word[3] != '-': wrong_position += guess_word[3] else: wrong_position += '*' if guess_word[4] in puzzle_word and guess_word[4] != '-': wrong_position += guess_word[4] else: wrong_position += '*' return wrong_position def replace_kth_letter_in_str(original_str, k, ch): replace = original_str[:k] + ch + original_str[k+1:] return replace def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = text colored_text = '' if (text[0] != '*' and text[0] != '?') : if color == 'green': colored_text += white_on_green + text[0] + normal if color == 'yellow': colored_text += white_on_yellow + text[0] + normal else : colored_text += text[0] if (text[1] != '*' and text[1] != '?') : if color == 'green': colored_text += white_on_green + text[1] + normal if color == 'yellow': colored_text += white_on_yellow + text[1] + normal else : colored_text += text[1] if (text[2] != '*' and text[2] != '?') : if color == 'green': colored_text += white_on_green + text[2] + normal if color == 'yellow': colored_text += white_on_yellow + text[2] + normal else : colored_text += text[2] if (text[3] != '*' and text[3] != '?') : if color == 'green': colored_text += white_on_green + text[3] + normal if color == 'yellow': colored_text += white_on_yellow + text[3] + normal else : colored_text += text[3] if (text[4] != '*' and text[4] != '?') : if color == 'green': colored_text += white_on_green + text[4] + normal if color == 'yellow': colored_text += white_on_yellow + text[4] + normal else : colored_text += text[4] return colored_text# 6432002121 sim = 71.27% import random import string def position_in_word(ch, word): if ch in word : if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = '' new_guess_word = guess_word new_puzzle_word = puzzle_word if new_guess_word[0] == new_puzzle_word[0] : correct += new_guess_word[0] new_guess_word = "-"+new_guess_word[1:5] new_puzzle_word = "-"+new_puzzle_word[1:5] else : correct += "?" if new_guess_word[1] == new_puzzle_word[1] : correct += new_guess_word[1] new_guess_word = new_guess_word[0]+"-"+new_guess_word[2:5] new_puzzle_word = new_puzzle_word[0]+"-"+new_puzzle_word[2:5] else : correct += "?" if new_guess_word[2] == new_puzzle_word[2] : correct += new_guess_word[2] new_guess_word = new_guess_word[0:2]+"-"+new_guess_word[3:5] new_puzzle_word = new_puzzle_word[0:2]+"-"+new_puzzle_word[3:5] else : correct += "?" if new_guess_word[3]== new_puzzle_word[3] : correct += new_guess_word[3] new_guess_word = new_guess_word[0:3]+"-"+new_guess_word[4:5] new_puzzle_word = new_puzzle_word[0:3]+"-"+new_puzzle_word[4:5] else : correct += "?" if new_guess_word[4]== new_puzzle_word[4] : correct += new_guess_word[4] new_guess_word = new_guess_word[0:4]+"-" new_puzzle_word = new_puzzle_word[0:4]+"-" else : correct += "?" return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = '' if guess_word[0] in puzzle_word and guess_word[0] != "-" : wrong_position += guess_word[0] else : wrong_position += "*" if guess_word[1] in puzzle_word and guess_word[1] != "-" : wrong_position += guess_word[1] else : wrong_position += "*" if guess_word[2] in puzzle_word and guess_word[2] != "-" : wrong_position += guess_word[2] else : wrong_position += "*" if guess_word[3] in puzzle_word and guess_word[3] != "-": wrong_position += guess_word[3] else : wrong_position += "*" if guess_word[4] in puzzle_word and guess_word[4] != "-": wrong_position += guess_word[4] else : wrong_position += "*" return wrong_position def replace_kth_letter_in_str(original_str, k, ch): return original_str[0:k] + ch + original_str[k+1:5] def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' ch1 = " " ch2 = " " ch3 = " " ch4 = " " ch5 = " " if text[0] != "?" and text[0] != "*" : if color == "yellow" : ch1 = white_on_yellow + text[0] + normal if color == "green" : ch1 = white_on_green + text[0] + normal else : ch1 = text[0] if text[1] != "?" and text[1] != "*" : if color == "yellow" : ch2 = white_on_yellow + text[1] + normal if color == "green" : ch2 = white_on_green + text[1] + normal else : ch2 = text[1] if text[2] != "?" and text[2] != "*" : if color == "yellow" : ch3 = white_on_yellow + text[2] + normal if color == "green" : ch3 = white_on_green + text[2] + normal else : ch3 = text[2] if text[3] != "?" and text[3] != "*" : if color == "yellow" : ch4 = white_on_yellow + text[3] + normal if color == "green" : ch4 = white_on_green + text[3] + normal else : ch4 = text[3] if text[4] != "?" and text[4] != "*" : if color == "yellow" : ch5 = white_on_yellow + text[4] + normal if color == "green" : ch5 = white_on_green + text[4] + normal else : ch5 = text[4] colored_text = ch1+ch2+ch3+ch4+ch5 return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #24(2)

# 6430286721 sim = 71.06% import random import string def position_in_word(ch, word): if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): a = puzzle_word b = guess_word if a[0] == b[0] : a0 = "-" b0 = a[0] c0 = "-" else : a0 = b[0] b0 = "?" c0 = a[0] if a[1] == b[1] : a1 = "-" b1 = a[1] c1 = "-" else : a1 = b[1] b1 = "?" c1 = a[1] if a[2] == b[2] : a2 = "-" b2 = a[2] c2 = "-" else : a2 = b[2] b2 = "?" c2 = a[2] if a[3] == b[3] : a3 = "-" b3 = a[3] c3 = "-" else : a3 = b[3] b3 = "?" c3 = a[3] if a[4] == b[4] : a4 = "-" b4 = a[4] c4 = "-" else : a4 = b[4] b4 = "?" c4 = a[4] new_guess_word = a0+a1+a2+a3+a4 correct = b0+b1+b2+b3+b4 new_puzzle_word = c0+c1+c2+c3+c4 return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): a = puzzle_word b = guess_word if b[0] in a : b0 = b[0] if b0 == "-" : b0 = "*" else : b0 = "*" if b0 in a : x = position_in_word(b0, a) y = replace_kth_letter_in_str(a,x ,1) a = y if b[1] in a : b1 = b[1] if b1 == "-" : b1 = "*" else : b1 = "*" if b1 in a : x = position_in_word(b1, a) y = replace_kth_letter_in_str(a,x ,1) a = y if b[2] in a : b2 = b[2] if b2 == "-" : b2 = "*" else : b2 = "*" if b2 in a : x = position_in_word(b2, a) y = replace_kth_letter_in_str(a,x ,1) a = y if b[3] in a : b3 = b[3] if b3 == "-" : b3 = "*" else : b3 = "*" if b3 in a : x = position_in_word(b3, a) y = replace_kth_letter_in_str(a,x ,1) a = y if b[4] in a : b4 = b[4] if b4 == "-" : b4 = "*" else : b4 = "*" wrong_position = b0+b1+b2+b3+b4 return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0 : x = "-" + original_str[1:] if k == 1 : x = original_str[0:1] + "-" + original_str[2:] if k==2 : x = original_str[0:2] + "-" + original_str[3:] if k==3 : x = original_str[0:3] + "-" + original_str[4:] if k==4 : x = original_str[0:4] + "-" + original_str[5:] return x def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if "A" <= text[0] <= "Z" : if color[0] == "g" : a0 = white_on_green + text[0] + normal if color[0] == "y" : a0 = white_on_yellow + text[0] + normal else : a0 = text[0] if "A" <= text[1] <= "Z" : if color[0] == "g" : a1 = white_on_green + text[1] + normal if color[0] == "y" : a1 = white_on_yellow + text[1] + normal else : a1 = text[1] if "A" <= text[2] <= "Z" : if color[0] == "g" : a2 = white_on_green + text[2] + normal if color[0] == "y" : a2 = white_on_yellow + text[2] + normal else : a2 = text[2] if "A" <= text[3] <= "Z" : if color[0] == "g" : a3 = white_on_green + text[3] + normal if color[0] == "y" : a3 = white_on_yellow + text[3] + normal else : a3 = text[3] if "A" <= text[4] <= "Z" : if color[0] == "g" : a4 = white_on_green + text[4] + normal if color[0] == "y" : a4 = white_on_yellow + text[4] + normal else : a4 = text[4] colored_text = a0+a1+a2+a3+a4 return colored_text# 6432198521 sim = 71.06% import random import string def position_in_word(ch, word): if ch == word[0] : position = 0 elif ch == word[1] : position = 1 elif ch == word[2] : position = 2 elif ch == word[3] : position = 3 elif ch == word[4] : position = 4 else : position = -1 return position def check_correct_position(puzzle_word, guess_word): if guess_word[0] == puzzle_word[0] : zero1 = '-' zero2 = guess_word[0] zero3 = '-' else : zero1 = guess_word[0] zero2 = '?' zero3 = puzzle_word[0] if guess_word[1] == puzzle_word[1] : one1 = '-' one2 = guess_word[1] one3 = '-' else : one1 = guess_word[1] one2 = '?' one3 = puzzle_word[1] if guess_word[2] == puzzle_word[2] : two1 = '-' two2 = guess_word[2] two3 = '-' else : two1 = guess_word[2] two2 = '?' two3 = puzzle_word[2] if guess_word[3] == puzzle_word[3] : three1 = '-' three2 = guess_word[3] three3 = '-' else : three1 = guess_word[3] three2 = '?' three3 = puzzle_word[3] if guess_word[4] == puzzle_word[4] : four1 = '-' four2 = guess_word[4] four3 = '-' else : four1 = guess_word[4] four2 = '?' four3 = puzzle_word[4] new_guess_word = zero1+one1+two1+three1+four1 correct = zero2+one2+two2+three2+four2 new_puzzle_word = zero3+one3+two3+three3+four3 return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): if guess_word[0] == '-' : gnew0 = '@' else : gnew0 = guess_word[0] if guess_word[1] == '-' : gnew1 = '@' else : gnew1 = guess_word[1] if guess_word[2] == '-' : gnew2 = '@' else : gnew2 = guess_word[2] if guess_word[3] == '-' : gnew3 = '@' else : gnew3 = guess_word[3] if guess_word[4] == '-' : gnew4 = '@' else : gnew4 = guess_word[4] guess_word = gnew0+gnew1+gnew2+gnew3+gnew4 if guess_word[0] in puzzle_word : a0 = guess_word[0] else : a0 = '*' if guess_word[1] in puzzle_word : a1 = guess_word[1] else : a1 = '*' if guess_word[2] in puzzle_word : a2 = guess_word[2] else : a2 = '*' if guess_word[3] in puzzle_word : a3 = guess_word[3] else : a3 = '*' if guess_word[4] in puzzle_word : a4 = guess_word[4] else : a4 = '*' wrong_position = a0+a1+a2+a3+a4 return wrong_position def replace_kth_letter_in_str(original_str, k, ch): if k == 0 : word = ch+original_str[1:5] if k == 1 : word = original_str[0:1]+ch+original_str[2:5] if k == 2 : word = original_str[0:2]+ch+original_str[3:5] if k == 3 : word = original_str[0:3]+ch+original_str[4:5] if k == 4 : word = original_str[0:4]+ch+original_str[5:5] return word def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' if text[0] in alphabet : if color == 'green' : t0 = white_on_green + text[0] + normal elif color == 'yellow' : t0 = white_on_yellow + text[0] + normal else : t0 = text[0] if text[1] in alphabet : if color == 'green' : t1 = white_on_green + text[1] + normal elif color == 'yellow' : t1 = white_on_yellow + text[1] + normal else : t1 = text[1] if text[2] in alphabet : if color == 'green' : t2 = white_on_green + text[2] + normal elif color == 'yellow' : t2 = white_on_yellow + text[2] + normal else : t2 = text[2] if text[3] in alphabet : if color == 'green' : t3 = white_on_green + text[3] + normal elif color == 'yellow' : t3 = white_on_yellow + text[3] + normal else : t3 = text[3] if text[4] in alphabet : if color == 'green' : t4 = white_on_green + text[4] + normal elif color == 'yellow' : t4 = white_on_yellow + text[4] + normal else : t4 = text[4] text = t0+t1+t2+t3+t4 colored_text = text return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #25(4)

# 6331218121 sim = 70.98% import random import string def position_in_word(ch, word): if ch in word[0]: position = 0 elif ch in word[1]: position = 1 elif ch in word[2]: position = 2 elif ch in word[3]: position = 3 elif ch in word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = ['?','?','?','?','?'] guess_word = [guess_word[0],guess_word[1],guess_word[2],guess_word[3],guess_word[4]] puzzle_word = [puzzle_word[0],puzzle_word[1],puzzle_word[2],puzzle_word[3],puzzle_word[4]] if guess_word[0] in puzzle_word[0]: correct[0] = guess_word[0] guess_word[0] = '-' puzzle_word[0] = '-' if guess_word[1] in puzzle_word[1]: correct[1] = guess_word[1] guess_word[1] = '-' puzzle_word[1] = '-' if guess_word[2] in puzzle_word[2]: correct[2] = guess_word[2] guess_word[2] = '-' puzzle_word[2] = '-' if guess_word[3] in puzzle_word[3]: correct[3] = guess_word[3] guess_word[3] = '-' puzzle_word[3] = '-' if guess_word[4] in puzzle_word[4]: correct[4] = guess_word[4] guess_word[4] = '-' puzzle_word[4] = '-' correct = correct[0]+correct[1]+correct[2]+correct[3]+correct[4] new_guess_word = guess_word[0]+guess_word[1]+guess_word[2]+ guess_word[3]+guess_word[4] puzzle_word = puzzle_word[0]+puzzle_word[1]+puzzle_word[2]+puzzle_word[3]+puzzle_word[4] new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): blank = ['*','*','*','*','*'] guess_word = [guess_word[0],guess_word[1],guess_word[2],guess_word[3],guess_word[4]] puzzle_word = [puzzle_word[0],puzzle_word[1],puzzle_word[2],puzzle_word[3],puzzle_word[4]] if guess_word[0] in puzzle_word: blank[0] = guess_word[0] if guess_word[0] == puzzle_word[0]: puzzle_word[0] = '*' elif guess_word[0] == puzzle_word[1]: puzzle_word[1] = '*' elif guess_word[0] == puzzle_word[2]: puzzle_word[2] = '*' elif guess_word[0] == puzzle_word[3]: puzzle_word[3] = '*' elif guess_word[0] == puzzle_word[4]: puzzle_word[4] = '*' if guess_word[1] in puzzle_word: blank[1] = guess_word[1] if guess_word[1] == puzzle_word[0]: puzzle_word[0] = '*' elif guess_word[1] == puzzle_word[1]: puzzle_word[1] = '*' elif guess_word[1] == puzzle_word[2]: puzzle_word[2] = '*' elif guess_word[1] == puzzle_word[3]: puzzle_word[3] = '*' elif guess_word[1] == puzzle_word[4]: puzzle_word[4] = '*' if guess_word[2] in puzzle_word: blank[2] = guess_word[2] if guess_word[2] == puzzle_word[0]: puzzle_word[0] = '*' elif guess_word[2] == puzzle_word[1]: puzzle_word[1] = '*' elif guess_word[2] == puzzle_word[2]: puzzle_word[2] = '*' elif guess_word[2] == puzzle_word[3]: puzzle_word[3] = '*' elif guess_word[2] == puzzle_word[4]: puzzle_word[4] = '*' if guess_word[3] in puzzle_word: blank[3] = guess_word[3] if guess_word[3] == puzzle_word[0]: puzzle_word[0] = '*' elif guess_word[3] == puzzle_word[1]: puzzle_word[1] = '*' elif guess_word[3] == puzzle_word[2]: puzzle_word[2] = '*' elif guess_word[3] == puzzle_word[3]: puzzle_word[3] = '*' elif guess_word[3] == puzzle_word[4]: puzzle_word[4] = '*' if guess_word[4] in puzzle_word: blank[4] = guess_word[4] if guess_word[4] == puzzle_word[0]: puzzle_word[0] = '*' elif guess_word[4] == puzzle_word[1]: puzzle_word[1] = '*' elif guess_word[4] == puzzle_word[2]: puzzle_word[2] = '*' elif guess_word[4] == puzzle_word[3]: puzzle_word[3] = '*' elif guess_word[4] == puzzle_word[4]: puzzle_word[4] = '*' if "-" in blank: if "-" in blank[0]: blank[0] = '*' if "-" in blank[1]: blank[1] = '*' if "-" in blank[2]: blank[2] = '*' if "-" in blank[3]: blank[3] = '*' if "-" in blank[4]: blank[4] = '*' wrong_position = blank[0]+blank[1]+blank[2]+blank[3]+blank[4] return wrong_position def replace_kth_letter_in_str(original_str, k, ch): original_str = [original_str[0],original_str[1],original_str[2],original_str[3],original_str[4]] original_str[k] = str(ch) original_str = original_str[0]+original_str[1]+original_str[2]+original_str[3]+original_str[4] return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' text = [text[0],text[1],text[2],text[3],text[4]] alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] if color == 'green': if text[0] in alphabet : text[0] = white_on_green + text[0] + normal if text[1] in alphabet : text[1] = white_on_green + text[1] + normal if text[2] in alphabet : text[2] = white_on_green + text[2] + normal if text[3] in alphabet : text[3] = white_on_green + text[3] + normal if text[4] in alphabet : text[4] = white_on_green + text[4] + normal text = text[0]+text[1]+text[2]+text[3]+text[4] if color == 'yellow': if text[0] in alphabet : text[0] = white_on_yellow + text[0] + normal if text[1] in alphabet : text[1] = white_on_yellow + text[1] + normal if text[2] in alphabet : text[2] = white_on_yellow + text[2] + normal if text[3] in alphabet : text[3] = white_on_yellow + text[3] + normal if text[4] in alphabet : text[4] = white_on_yellow + text[4] + normal text = text[0]+text[1]+text[2]+text[3]+text[4] colored_text = text return colored_text# 6432060521 sim = 70.98% import random import string def position_in_word(ch, word): position = 0 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): correct=["?","?","?","?","?"] guess_word=[guess_word[0],guess_word[1],guess_word[2],guess_word[3],guess_word[4]] puzzle_word=[puzzle_word[0],puzzle_word[1],puzzle_word[2],puzzle_word[3],puzzle_word[4]] if puzzle_word[0] == guess_word[0]: correct[0]=guess_word[0] puzzle_word[0]="-" guess_word[0]="-" if puzzle_word[1] == guess_word[1]: correct[1]=guess_word[1] puzzle_word[1]="-" guess_word[1]="-" if puzzle_word[2] == guess_word[2]: correct[2]=guess_word[2] puzzle_word[2]="-" guess_word[2]="-" if puzzle_word[3] == guess_word[3]: correct[3]=guess_word[3] puzzle_word[3]="-" guess_word[3]="-" if puzzle_word[4] == guess_word[4]: correct[4]=guess_word[4] puzzle_word[4]="-" guess_word[4]="-" correct = "".join(correct) new_puzzle_word="".join(puzzle_word) new_guess_word="".join(guess_word) return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = ["*","*","*","*","*"] x = puzzle_word guess_word = [guess_word[0],guess_word[1],guess_word[2],guess_word[3],guess_word[4]] puzzle_word = [puzzle_word[0],puzzle_word[1],puzzle_word[2],puzzle_word[3],puzzle_word[4]] if guess_word[0] in puzzle_word and guess_word[0] != "-" : wrong_position[0]=guess_word[0] if guess_word[0] == puzzle_word[0]: puzzle_word[0] = "-" elif guess_word[0] == puzzle_word[1]: puzzle_word[1] = "-" elif guess_word[0] == puzzle_word[2]: puzzle_word[2] = "-" elif guess_word[0] == puzzle_word[3]: puzzle_word[3] = "-" elif guess_word[0] == puzzle_word[4]: puzzle_word[4] = "-" if guess_word[1] in puzzle_word and guess_word[1] != "-" : wrong_position[1]=guess_word[1] if guess_word[1] == puzzle_word[0]: puzzle_word[0] = "-" elif guess_word[1] == puzzle_word[1]: puzzle_word[1] = "-" elif guess_word[1] == puzzle_word[2]: puzzle_word[2] = "-" elif guess_word[1] == puzzle_word[3]: puzzle_word[3] = "-" elif guess_word[1] == puzzle_word[4]: puzzle_word[4] = "-" if guess_word[2] in puzzle_word and guess_word[2] != "-" : wrong_position[2]=guess_word[2] if guess_word[2] == puzzle_word[0]: puzzle_word[0] = "-" elif guess_word[2] == puzzle_word[1]: puzzle_word[1] = "-" elif guess_word[2] == puzzle_word[2]: puzzle_word[2] = "-" elif guess_word[2] == puzzle_word[3]: puzzle_word[3] = "-" elif guess_word[2] == puzzle_word[4]: puzzle_word[4] = "-" if guess_word[3] in puzzle_word and guess_word[3] != "-" : wrong_position[3]=guess_word[3] if guess_word[3] == puzzle_word[0]: puzzle_word[0] = "-" elif guess_word[3] == puzzle_word[1]: puzzle_word[1] = "-" elif guess_word[3] == puzzle_word[2]: puzzle_word[2] = "-" elif guess_word[3] == puzzle_word[3]: puzzle_word[3] = "-" elif guess_word[3] == puzzle_word[4]: puzzle_word[4] = "-" if guess_word[4] in puzzle_word and guess_word[4] != "-" : wrong_position[4]=guess_word[4] if guess_word[4] == puzzle_word[0]: puzzle_word[0] = "-" elif guess_word[4] == puzzle_word[1]: puzzle_word[1] = "-" elif guess_word[4] == puzzle_word[2]: puzzle_word[2] = "-" elif guess_word[4] == puzzle_word[3]: puzzle_word[3] = "-" elif guess_word[4] == puzzle_word[4]: puzzle_word[4] = "-" wrong_position="".join(wrong_position) puzzle_word = x return wrong_position def replace_kth_letter_in_str(original_str, k, ch): original_str=[original_str[0],original_str[1],original_str[2],original_str[3],original_str[4]] original_str[k]=ch original_str="".join(original_str) return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' x=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] if color == "green" : if text[0] in x: text0 = white_on_green+text[0]+normal else : text0 = text[0] if text[1] in x: text1 = white_on_green+text[1]+normal else : text1 = text[1] if text[2] in x: text2 = white_on_green+text[2]+normal else : text2 = text[2] if text[3] in x: text3 = white_on_green+text[3]+normal else : text3 = text[3] if text[4] in x: text4 = white_on_green+text[4]+normal else : text4 = text[4] if color == "yellow" : if text[0] in x: text0 = white_on_yellow+text[0]+normal else : text0 = text[0] if text[1] in x: text1 = white_on_yellow+text[1]+normal else : text1 = text[1] if text[2] in x: text2 = white_on_yellow+text[2]+normal else : text2 = text[2] if text[3] in x: text3 = white_on_yellow+text[3]+normal else : text3 = text[3] if text[4] in x: text4 = white_on_yellow+text[4]+normal else : text4 = text[4] colored_text = text0+text1+text2+text3+text4 return colored_text# 6430198121 sim = 70.87% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): correct = '?????' correct = list(correct) guess_word = list(guess_word) puzzle_word = list(puzzle_word) if puzzle_word[0] == guess_word[0]: guess_word[0] = '-' correct[0] = puzzle_word[0] puzzle_word[0] = '-' if puzzle_word[1] == guess_word[1]: guess_word[1] = '-' correct[1] = puzzle_word[1] puzzle_word[1] = '-' if puzzle_word[2] == guess_word[2]: guess_word[2] = '-' correct[2] = puzzle_word[2] puzzle_word[2] = '-' if puzzle_word[3] == guess_word[3]: guess_word[3] = '-' correct[3] = puzzle_word[3] puzzle_word[3] = '-' if puzzle_word[4] == guess_word[4]: guess_word[4] = '-' correct[4] = puzzle_word[4] puzzle_word[4] = '-' guess_word = ''.join(guess_word) puzzle_word = ''.join(puzzle_word) correct = ''.join(correct) new_guess_word = guess_word new_puzzle_word = puzzle_word return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): guess_word = list(guess_word) puzzle_word = list(puzzle_word) wrong = '*****' wrong = list(wrong) if guess_word[0] != '-': if guess_word[0] in puzzle_word: wrong[0] = guess_word[0] if guess_word[0] == puzzle_word[1]: puzzle_word[1] = '-' elif guess_word[0] == puzzle_word[2]: puzzle_word[2] = '-' elif guess_word[0] == puzzle_word[3]: puzzle_word[3] = '-' elif guess_word[0] == puzzle_word[4]: puzzle_word[4] = '-' if guess_word[1] != '-': if guess_word[1] in puzzle_word: wrong[1] = guess_word[1] if guess_word[1] == puzzle_word[0]: puzzle_word[0] = '-' elif guess_word[1] == puzzle_word[2]: puzzle_word[2] = '-' elif guess_word[1] == puzzle_word[3]: puzzle_word[3] = '-' elif guess_word[1] == puzzle_word[4]: puzzle_word[4] = '-' if guess_word[2] != '-': if guess_word[2] in puzzle_word: wrong[2] = guess_word[2] if guess_word[2] == puzzle_word[1]: puzzle_word[1] = '-' elif guess_word[2] == puzzle_word[0]: puzzle_word[0] = '-' elif guess_word[2] == puzzle_word[3]: puzzle_word[3] = '-' elif guess_word[2] == puzzle_word[4]: puzzle_word[4] = '-' if guess_word[3] != '-': if guess_word[3] in puzzle_word: wrong[3] = guess_word[3] if guess_word[3] == puzzle_word[1]: puzzle_word[1] = '-' elif guess_word[3] == puzzle_word[2]: puzzle_word[2] = '-' elif guess_word[3] == puzzle_word[0]: puzzle_word[0] = '-' elif guess_word[3] == puzzle_word[4]: puzzle_word[4] = '-' if guess_word[4] != '-': if guess_word[4] in puzzle_word: wrong[4] = guess_word[4] if guess_word[4] == puzzle_word[1]: puzzle_word[1] = '-' elif guess_word[4] == puzzle_word[2]: puzzle_word[2] = '-' elif guess_word[4] == puzzle_word[3]: puzzle_word[3] = '-' elif guess_word[4] == puzzle_word[0]: puzzle_word[0] = '-' guess_word = ''.join(guess_word) puzzle_word = ''.join(puzzle_word) wrong = ''.join(wrong) wrong_position = wrong return wrong_position def replace_kth_letter_in_str(original_str, k, ch): original_str = list(original_str) if k == 0: original_str[0] = '-' if k == 1: original_str[1] = '-' if k == 2: original_str[2] = '-' if k == 3: original_str[3] = '-' if k == 4: original_str[4] = '-' original_str = ''.join(original_str) return original_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' text = list(text) if color == 'green': if text[0] != '?': text[0] = white_on_green + text[0] +normal if text[1] != '?': text[1] = white_on_green + text[1] +normal if text[2] != '?': text[2] = white_on_green + text[2] +normal if text[3] != '?': text[3] = white_on_green + text[3] +normal if text[4] != '?': text[4] = white_on_green + text[4] +normal if color == 'yellow': if text[0] != '*': text[0] = white_on_yellow + text[0] +normal if text[1] != '*': text[1] = white_on_yellow + text[1] +normal if text[2] != '*': text[2] = white_on_yellow + text[2] +normal if text[3] != '*': text[3] = white_on_yellow + text[3] +normal if text[4] != '*': text[4] = white_on_yellow + text[4] +normal text = ''.join(text) colored_text = text return colored_text# 6430204221 sim = 70.87% import random import string def position_in_word(ch, word): if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 else: position = -1 return position def check_correct_position(puzzle_word, guess_word): correct = ['?','?','?','?','?'] new_guess_word = [guess_word[0],guess_word[1],guess_word[2],guess_word[3],guess_word[4]] new_puzzle_word = [puzzle_word[0],puzzle_word[1],puzzle_word[2],puzzle_word[3],puzzle_word[4]] if puzzle_word[0] == guess_word[0]: new_guess_word[0] = '-' correct[0] = puzzle_word[0] new_puzzle_word[0] = '-' if puzzle_word[1] == guess_word[1]: new_guess_word[1] = '-' correct[1] = puzzle_word[1] new_puzzle_word[1] = '-' if puzzle_word[2] == guess_word[2]: new_guess_word[2] = '-' correct[2] = puzzle_word[2] new_puzzle_word[2] = '-' if puzzle_word[3] == guess_word[3]: new_guess_word[3] = '-' correct[3] = puzzle_word[3] new_puzzle_word[3] = '-' if puzzle_word[4] == guess_word[4]: new_guess_word[4] = '-' correct[4] = puzzle_word[4] new_puzzle_word[4] = '-' new_guess_word = "".join(new_guess_word) correct = "".join(correct) new_puzzle_word = "".join(new_puzzle_word) return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): wrong_position = ['*','*','*','*','*'] puz = [puzzle_word[0],puzzle_word[1],puzzle_word[2],puzzle_word[3],puzzle_word[4]] if (guess_word[0] in puz ) and (guess_word[0] != puzzle_word[0]): if guess_word[0] == puz[1]: puz[1] = '' elif guess_word[0] == puz[2]: puz[2] = '' elif guess_word[0] == puz[3]: puz[3] = '' elif guess_word[0] == puz[4]: puz[4] = '' wrong_position[0] = guess_word[0] if (guess_word[1] in puz ) and (guess_word[1] != puzzle_word[1]): if guess_word[1] == puz[0]: puz[0] = '' elif guess_word[1] == puz[2]: puz[2] = '' elif guess_word[1] == puz[3]: puz[3] = '' elif guess_word[1] == puz[4]: puz[4] = '' wrong_position[1] = guess_word[1] if (guess_word[2] in puz ) and (guess_word[2] != puzzle_word[2]): if guess_word[2] == puz[0]: puz[0] = '' elif guess_word[2] == puz[1]: puz[1] = '' elif guess_word[2] == puz[3]: puz[3] = '' elif guess_word[2] == puz[4]: puz[4] = '' wrong_position[2] = guess_word[2] if (guess_word[3] in puz ) and (guess_word[3] != puzzle_word[3]): if guess_word[3] == puz[0]: puz[0] = '' elif guess_word[3] == puz[1]: puz[1] = '' elif guess_word[3] == puz[2]: puz[2] = '' elif guess_word[3] == puz[4]: puz[4] = '' wrong_position[3] = guess_word[3] if (guess_word[4] in puz ) and (guess_word[4] != puzzle_word[4]): if guess_word[4] == puz[0]: puz[0] = '' elif guess_word[4] == puz[1]: puz[1] = '' elif guess_word[4] == puz[2]: puz[2] = '' elif guess_word[4] == puz[3]: puz[3] = '' wrong_position[4] = guess_word[4] wrong_position = "".join(wrong_position) return wrong_position def replace_kth_letter_in_str(original_str, k, ch): ans = [original_str[0],original_str[1],original_str[2],original_str[3],original_str[4]] ans[k] = ch ans = "".join(ans) return ans def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = [text[0],text[1],text[2],text[3],text[4]] if color == 'green': if 'A' <=text[0]<= 'Z': colored_text[0] = white_on_green + text[0] + normal if 'A' <=text[1]<= 'Z': colored_text[1] = white_on_green + text[1] + normal if 'A' <=text[2]<= 'Z': colored_text[2] = white_on_green + text[2] + normal if 'A' <=text[3]<= 'Z': colored_text[3] = white_on_green + text[3] + normal if 'A' <=text[4]<= 'Z': colored_text[4] = white_on_green + text[4] + normal elif color == 'yellow': if 'A' <=text[0]<= 'Z': colored_text[0] = white_on_yellow + text[0] + normal if 'A' <=text[1]<= 'Z': colored_text[1] = white_on_yellow + text[1] + normal if 'A' <=text[2]<= 'Z': colored_text[2] = white_on_yellow + text[2] + normal if 'A' <=text[3]<= 'Z': colored_text[3] = white_on_yellow + text[3] + normal if 'A' <=text[4]<= 'Z': colored_text[4] = white_on_yellow + text[4] + normal colored_text = "".join(colored_text) return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #26(2)

# 6430309521 sim = 70.23% import random import string def position_in_word(ch, word): position = -1 if word[0] == ch: position = 0 elif word[1] == ch: position = 1 elif word[2] == ch: position = 2 elif word[3] == ch: position = 3 elif word[4] == ch: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word j=0 if puzzle_word[j] == guess_word[j]: new_guess_word = replace_kth_letter_in_str(new_guess_word, j, "-") correct += puzzle_word[j] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, j, "-") else: correct += "?" j=1 if puzzle_word[j] == guess_word[j]: new_guess_word = replace_kth_letter_in_str(new_guess_word, j, "-") correct += puzzle_word[j] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, j, "-") else: correct += "?" j=2 if puzzle_word[j] == guess_word[j]: new_guess_word = replace_kth_letter_in_str(new_guess_word, j, "-") correct += puzzle_word[j] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, j, "-") else: correct += "?" j=3 if puzzle_word[j] == guess_word[j]: new_guess_word = replace_kth_letter_in_str(new_guess_word, j, "-") correct += puzzle_word[j] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, j, "-") else: correct += "?" j=4 if puzzle_word[j] == guess_word[j]: new_guess_word = replace_kth_letter_in_str(new_guess_word, j, "-") correct += puzzle_word[j] new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, j, "-") else: correct += "?" return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): new = original_str[0:k] + ch + original_str[k+1:5] return new def check_wrong_position(puzzle_word, guess_word): wrong_position = '' i=0 if puzzle_word[i] != '-' and guess_word[i] in puzzle_word: wrong_position += guess_word[i] m = position_in_word(guess_word[i], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, m, ".") else: wrong_position += "*" i=1 if puzzle_word[i] != '-' and guess_word[i] in puzzle_word: wrong_position += guess_word[i] m = position_in_word(guess_word[i], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, m, ".") else: wrong_position += "*" i=2 if puzzle_word[i] != '-' and guess_word[i] in puzzle_word: wrong_position += guess_word[i] m = position_in_word(guess_word[i], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, m, ".") else: wrong_position += "*" i=3 if puzzle_word[i] != '-' and guess_word[i] in puzzle_word: wrong_position += guess_word[i] m = position_in_word(guess_word[i], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, m, ".") else: wrong_position += "*" i=4 if puzzle_word[i] != '-' and guess_word[i] in puzzle_word: wrong_position += guess_word[i] m = position_in_word(guess_word[i], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, m, ".") else: wrong_position += "*" return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' colored_text = '' if color == "green": if text[0] != "?": colored_text += white_on_green + text[0] + normal else: colored_text += '?' if text[1] != "?": colored_text += white_on_green + text[1] + normal else: colored_text += '?' if text[2] != "?": colored_text += white_on_green + text[2] + normal else: colored_text += '?' if text[3] != "?": colored_text += white_on_green + text[3] + normal else: colored_text += '?' if text[4] != "?": colored_text += white_on_green + text[4] + normal else: colored_text += '?' elif color == "yellow": if text[0] != "*": colored_text += white_on_yellow + text[0] + normal else: colored_text += '*' if text[1] != "*": colored_text += white_on_yellow + text[1] + normal else: colored_text += '*' if text[2] != "*": colored_text += white_on_yellow + text[2] + normal else: colored_text += '*' if text[3] != "*": colored_text += white_on_yellow + text[3] + normal else: colored_text += '*' if text[4] != "*": colored_text += white_on_yellow + text[4] + normal else: colored_text += '*' return colored_text# 6432072021 sim = 70.23% import random import string def position_in_word(ch, word): position = -1 if ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): new_guess_word = guess_word correct = '' new_puzzle_word = puzzle_word i = 0 if puzzle_word[i] == guess_word[i]: correct += puzzle_word[i] new_guess_word = replace_kth_letter_in_str(new_guess_word, i, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, i, '-') else: correct += '?' i += 1 if puzzle_word[i] == guess_word[i]: correct += puzzle_word[i] new_guess_word = replace_kth_letter_in_str(new_guess_word, i, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, i, '-') else: correct += '?' i += 1 if puzzle_word[i] == guess_word[i]: correct += puzzle_word[i] new_guess_word = replace_kth_letter_in_str(new_guess_word, i, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, i, '-') else: correct += '?' i += 1 if puzzle_word[i] == guess_word[i]: correct += puzzle_word[i] new_guess_word = replace_kth_letter_in_str(new_guess_word, i, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, i, '-') else: correct += '?' i += 1 if puzzle_word[i] == guess_word[i]: correct += puzzle_word[i] new_guess_word = replace_kth_letter_in_str(new_guess_word, i, '-') new_puzzle_word = replace_kth_letter_in_str(new_puzzle_word, i, '-') else: correct += '?' return new_guess_word, correct, new_puzzle_word def replace_kth_letter_in_str(original_str, k, ch): return original_str[:k] + ch + original_str[:k:-1][::-1] def check_wrong_position(puzzle_word, guess_word): wrong_position = '' i = 0 if guess_word[i] in puzzle_word and guess_word[i] != '-' : wrong_position += guess_word[i] n = position_in_word(guess_word[i], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, n, ' ') else: wrong_position += '*' i += 1 if guess_word[i] in puzzle_word and guess_word[i] != '-' : wrong_position += guess_word[i] n = position_in_word(guess_word[i], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, n, ' ') else: wrong_position += '*' i += 1 if guess_word[i] in puzzle_word and guess_word[i] != '-' : wrong_position += guess_word[i] n = position_in_word(guess_word[i], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, n, ' ') else: wrong_position += '*' i += 1 if guess_word[i] in puzzle_word and guess_word[i] != '-' : wrong_position += guess_word[i] n = position_in_word(guess_word[i], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, n, ' ') else: wrong_position += '*' i += 1 if guess_word[i] in puzzle_word and guess_word[i] != '-' : wrong_position += guess_word[i] n = position_in_word(guess_word[i], puzzle_word) puzzle_word = replace_kth_letter_in_str(puzzle_word, n, ' ') else: wrong_position += '*' i += 1 return wrong_position def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' if color == 'green' : paint = white_on_green elif color == 'yellow': paint = white_on_yellow i = 0 if 'A' <= text[i] <= 'Z': ch0 = paint + text[i] + normal else: ch0 = text[i] i += 1 if 'A' <= text[i] <= 'Z': ch1 = paint + text[i] + normal else: ch1 = text[i] i += 1 if 'A' <= text[i] <= 'Z': ch2 = paint + text[i] + normal else: ch2 = text[i] i += 1 if 'A' <= text[i] <= 'Z': ch3 = paint + text[i] + normal else: ch3 = text[i] i += 1 if 'A' <= text[i] <= 'Z': ch4 = paint + text[i] + normal else: ch4 = text[i] colored_text = ch0 + ch1 + ch2 + ch3 + ch4 return colored_text

position_in_word,check_correct_position,check_wrong_position,replace_kth_letter_in_str,color_text: cluster #27(2)

# 6430194621 sim = 70.02% import random import string def position_in_word(ch, word): word = list(word) if ch not in word: position = -1 elif ch == word[0]: position = 0 elif ch == word[1]: position = 1 elif ch == word[2]: position = 2 elif ch == word[3]: position = 3 elif ch == word[4]: position = 4 return position def check_correct_position(puzzle_word, guess_word): a = list(guess_word) b = list(puzzle_word) correct = list('?????') if a[0] == b[0]: correct[0] = a[0] a[0] = '-' b[0] = '-' if a[1] == b[1]: correct[1] = a[1] a[1] = '-' b[1] = '-' if a[2] == b[2]: correct[2] = a[2] a[2] = '-' b[2] = '-' if a[3] == b[3]: correct[3] = a[3] a[3] = '-' b[3] = '-' if a[4] == b[4]: correct[4] = a[4] a[4] = '-' b[4] = '-' correct = ''.join(correct) new_puzzle_word = ''.join(b) new_guess_word = ''.join(a) return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): b = list(puzzle_word) a = list(guess_word) wrong = list('*****') if a[0] in b and a[0] != b[0]: wrong[0] = a[0] if a[1] in b and a[1] != b[1]: wrong[1] = a[1] if a[2] in b and a[2] != b[2]: wrong[2] = a[2] if a[3] in b and a[3] != b[3]: wrong[3] = a[3] if a[4] in b and a[4] != b[4]: wrong[4] = a[4] wrong_position = ''.join(wrong) return wrong_position def replace_kth_letter_in_str(original_str, k, ch): a = original_str if k == 0: new_str = ch + a[1:] if k == 1: new_str = a[:1] + ch + a[2:] if k == 2: new_str = a[:2] + ch + a[3:] if k == 3: new_str = a[:3] + ch + a[4:] if k == 4: new_str = a[:4] + ch return new_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' a = list(text) if color == 'green': if a[0] != '?' and a[0] != '*': a[0] = white_on_green + a[0] + normal if a[1] != '?' and a[1] != '*': a[1] = white_on_green + a[1] + normal if a[2] != '?' and a[2] != '*': a[2] = white_on_green + a[2] + normal if a[3] != '?' and a[3] != '*': a[3] = white_on_green + a[3] + normal if a[4] != '?' and a[4] != '*': a[4] = white_on_green + a[4] + normal elif color == 'yellow': if a[0] != '?' and a[0] != '*': a[0] = white_on_yellow + a[0] + normal if a[1] != '?' and a[1] != '*': a[1] = white_on_yellow + a[1] + normal if a[2] != '?' and a[2] != '*': a[2] = white_on_yellow + a[2] + normal if a[3] != '?' and a[3] != '*': a[3] = white_on_yellow + a[3] + normal if a[4] != '?' and a[4] != '*': a[4] = white_on_yellow + a[4] + normal colour_text = ''.join(a) return colour_text# 6430261021 sim = 70.02% import random import string def position_in_word(ch, word): x = list(word) position = -1 if ch in x[0]: position = 0 elif ch in x[1]: position = 1 elif ch in x[2]: position = 2 elif ch in x[3]: position = 3 elif ch in x[4]: position = 4 else: pass return position def check_correct_position(puzzle_word, guess_word): pz = list(puzzle_word) gs = list(guess_word) ngw = gs[::] cor = ['?'] * 5 npw = pz[::] if pz[0] == gs[0]: ngw[0] = "-" cor[0] = gs[0] npw[0] = "-" if pz[1] == gs[1]: ngw[1] = "-" cor[1] = gs[1] npw[1] = "-" if pz[2] == gs[2]: ngw[2] = "-" cor[2] = gs[2] npw[2] = "-" if pz[3] == gs[3]: ngw[3] = "-" cor[3] = gs[3] npw[3] = "-" if pz[4] == gs[4]: ngw[4] = "-" cor[4] = gs[4] npw[4] = "-" new_guess_word = ''.join(ngw) correct = ''.join(cor) new_puzzle_word = ''.join(npw) return new_guess_word, correct, new_puzzle_word def check_wrong_position(puzzle_word, guess_word): pz = list(puzzle_word) gs = list(guess_word) w_p = ['*'] * 5 if gs[0] in pz and gs[0] != "-": w_p[0] = gs[0] change_alphabet_to_hyphen(gs[0], pz) if gs[1] in pz and gs[1] != "-" : w_p[1] = gs[1] change_alphabet_to_hyphen(gs[1], pz) if gs[2] in pz and gs[2] != "-" : w_p[2] = gs[2] change_alphabet_to_hyphen(gs[2], pz) if gs[3] in pz and gs[3] != "-" : w_p[3] = gs[3] change_alphabet_to_hyphen(gs[3], pz) if gs[4] in pz and gs[4] != "-": w_p[4] = gs[4] change_alphabet_to_hyphen(gs[4], pz) wrong_position = ''.join(w_p) return wrong_position def change_alphabet_to_hyphen(x, y): if x == y[0]: y[0] = '-' elif x == y[1]: y[1] = '-' elif x == y[2]: y[2] = '-' elif x == y[3]: y[3] = '-' elif x == y[4]: y[4] = '-' def replace_kth_letter_in_str(original_str, k, ch): ori = list(original_str) ori[int(k)] = ch new_str = ''.join(ori) return new_str def color_text(text, color): white_on_green = '\033[37;42m' white_on_yellow = '\033[34;43m' normal = '\033[0;0m' tx_lst = list(text) if color == 'green': if tx_lst[0] != "?" and tx_lst[0] != "*": tx_lst[0] = white_on_green + tx_lst[0] + normal if tx_lst[1] != "?" and tx_lst[1] != "*": tx_lst[1] = white_on_green + tx_lst[1] + normal if tx_lst[2] != "?" and tx_lst[2] != "*": tx_lst[2] = white_on_green + tx_lst[2] + normal if tx_lst[3] != "?" and tx_lst[3] != "*": tx_lst[3] = white_on_green + tx_lst[3] + normal if tx_lst[4] != "?" and tx_lst[4] != "*": tx_lst[4] = white_on_green + tx_lst[4] + normal if color == 'yellow': if tx_lst[0] != "?" and tx_lst[0] != "*": tx_lst[0] = white_on_yellow + tx_lst[0] + normal if tx_lst[1] != "?" and tx_lst[1] != "*": tx_lst[1] = white_on_yellow + tx_lst[1] + normal if tx_lst[2] != "?" and tx_lst[2] != "*": tx_lst[2] = white_on_yellow + tx_lst[2] + normal if tx_lst[3] != "?" and tx_lst[3] != "*": tx_lst[3] = white_on_yellow + tx_lst[3] + normal if tx_lst[4] != "?" and tx_lst[4] != "*": tx_lst[4] = white_on_yellow + tx_lst[4] + normal colored_text = ''.join(tx_lst) return colored_text