Flames Game in Python

1. Introduction

The FLAMES game is a fun way to predict the relationship between two people based on their names. The acronym FLAMES stands for Friends, Love, Affection, Marriage, Enemy, and Sibling. The game calculates the result by counting the number of letters in the names that are unique and then cycling through the letters of FLAMES until only one letter remains. This tutorial will guide you through creating the FLAMES game in Python.

Flames Game in Python

2. Program Steps

1. Take two names as input from the user.

2. Remove the common characters in both names.

3. Count the total number of remaining characters.

4. Use the count to cycle through the FLAMES acronym and find the result.

5. Display the relationship prediction.

3. Code Program

def remove_common_characters(name1, name2):
    """Removes common characters in both names and returns the concatenated unique characters."""
    for character in name1[:]:  # Duplicate name1 to avoid modifying the loop variable
        if character in name2:
            name1 = name1.replace(character, '', 1)
            name2 = name2.replace(character, '', 1)
    return name1 + name2

def predict_relationship(remaining_characters):
    """Predicts the relationship based on the count of remaining characters."""
    flames = 'FLAMES'
    while len(flames) > 1:
        index = remaining_characters % len(flames) - 1
        if index >= 0:
            flames = flames[index + 1:] + flames[:index]
            flames = flames[:-1]
    return flames

# Step 1: Input names
name1 = input("Enter the first name: ").lower().replace(" ", "")
name2 = input("Enter the second name: ").lower().replace(" ", "")

# Step 2 & 3: Remove common characters and count the remaining
unique_characters = remove_common_characters(name1, name2)
remaining_characters_count = len(unique_characters)

# Step 4: Use the count to find the result from FLAMES
relationship = predict_relationship(remaining_characters_count)

# Step 5: Display the result
relationship_dict = {'F': 'Friends', 'L': 'Love', 'A': 'Affection',
                     'M': 'Marriage', 'E': 'Enemies', 'S': 'Siblings'}
print(f"The relationship is: {relationship_dict[relationship]}")


Enter the first name: Ramesh
Enter the second name: Prakash
The relationship is: Friends


1. The program begins by taking two names as input from the user. These names are converted to lowercase and spaces are removed to standardize the input.

2. The remove_common_characters function iterates over each character in the first name and removes it from both names if it is found in the second name. This process results in a string of characters that are unique to both names.

3. The length of this concatenated string of unique characters is calculated, which will be used to cycle through the FLAMES acronym.

4. The predict_relationship function cycles through the FLAMES string based on the count of remaining unique characters. It repeatedly trims the FLAMES string until only one character remains.

5. The final character corresponds to a result in the FLAMES acronym, which is then mapped to its full form (e.g., 'F' to 'Friends') and displayed to the user.

This simple FLAMES game demonstrates string manipulation, loops, and basic algorithmic thinking in Python.