Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Word Game using python #565 #566

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
def is_winning_string(string):
"""
Checks if a given string is a winning string.

Args:
string: The input string.

Returns:
True if the string is a winning string, False otherwise.
"""

partner_map = {
'a': 'n', 'b': 'o', 'c': 'p', 'd': 'q', 'e': 'r', 'f': 's', 'g': 't', 'h': 'u',
'i': 'v', 'j': 'w', 'k': 'x', 'l': 'y', 'm': 'z'
}

for i in range(0, len(string), 2):
if string[i] not in partner_map or string[i+1] != partner_map[string[i]]:
return False
return True

# Example usage:
string1 = "anbopq"
string2 = "azbycx"
string3 = "anboq"

print(is_winning_string(string1)) # Output: True
print(is_winning_string(string2)) # Output: True
print(is_winning_string(string3)) # Output: False