Python | A program for the implementation of a simple game FLAMES

Counters | Python Methods and Functions

FLAMES — popular game named after the acronym: Friends, Lovers, Affectionate, Marriage, Enemies, Brother and Sister. This game cannot accurately predict if a person is right for you or not, but it can be fun to play this game with your friends.

There are two steps in this game:

    Get score:
  • Take two names.
  • Remove common characters with their corresponding common cases.
  • Get the number of characters that remained.

Get the result:

  • Take the letters FLAMES as ["F", "L", "A", "M", "E", "S"]
  • Start deleting the email using the amount we received.
  • The email that completes the process is the result.
  • Example:

 Input: player1 name: AJAY player 2 name: PRIYA Output: Relationship status: Friends 

Explanation: In the above two names A and Y — common letters that occur once (common count) in both names, so we remove those letters from both names. Now count the total number of letters left here. Now start deleting letters one by one from FLAMES using the counter we got and the letter that lasts the whole process is the result.

The counting is done in a counter-clockwise circle.

counting is start from F, E is at 5th count so we remove E and start counting again but a this time start from S.
M is at 5th count so we remove M and counting start from S.
S is at 5th count so we remove S and counting start from F.
L is at 5th count so we remove L and counting start from A.
A is at 5th count so we remove A. now we have only one letter is remaining so this is the final answer.
So, the relationship is F ie Friends.

Approach: take two names as input, then remove the common characters with their corresponding common occurrences. To remove the target, we create a custom function remove_match_char with two arguments, such as remove_match_char and list2, which stores a character list of the two players' name respectively and returns a linked list list (list1 + "* "Flagst2) and the flag value we store in the ret_list variable. After removing all common characters, count the total. from the remaining characters, then create a list of results abbreviated as FLAMES, that is, [Friends, Love, Love, Marriage, Enemy, Brothers and Sisters]]. Now start deleting the word one by one until the list only contains one word using the total we got. The word that remains in the latter is the result.

Below is the implementation:

# function to remove common characters
# with their respective cases

def remove_match_char ( list1, list2):


for i in range ( len (list1)):

for j in range ( len (list2)):


# if a common symbol is found

  # then remove that character

# and return a concatenated list

# list with Type flag

if list1 [i] = = list2 [j]:

c = list1 [i]


  # remove character from the list

list1.remove (c)

list2.remove (c)


# concatenate two list items with *

# * acts as a border mark here

list3 = list1 + [ " * " ] + list2


  # return merged list with True flag

return [list3, True ]


# no common characters found

# return the concatenated list with False flag

list3 = list1 + [ " * " ] + list2

return [list3, False ]

# Driver code


if __ name__ = = "__ main__" :


# take name

  p1 = input ( "Player 1 name:" )


# converted all letters to lowercase

p1 = p1.lower ()


# replace any space with an empty string

  p1.replace ( "" , "")


# make a list of letters or symbols

p1_list = list (p1)


  # take the second name

p2 = input ( "Player 2 name: " )

  p2 < code class = "keyword"> = p2.lower ()

p2.replace ( "" , "")

p2_list = list (p2)


# initially accepting the flag as True

proceed = True


  # keep calling remove_match_char

# no common characters found or

  # keep looping until the continue flag is True

  while proceed:


# call the function and save the return value

ret_list = remove_match_char (p1_list, p2_list )


# remove the compound list from the return list

  con_list = ret_list [ 0 ]


  # retrieve the flag value from the return list

proceed = ret_list [ 1 ]


# find index & quot; * & quot; / border mark

star_index = con_list.index ( "*" )


# slice the list


# all characters before * store in p1_list

p1_list = con_list [: star_index]


# all characters after * save to p2_list

p2_list = con_list [star_index + 1 :]



# total remaining characters

count = len (p1_list) + len (p2_list)


# list of abbreviations FLAMES

result = [ "Friends" , "L ove " , " Affection " , "Marriage" , "Enemy" , "Siblings" ]


# keep looping until just one element

# not left in the list of results

while len (result) & gt;  1 :


# save this index value from

  # where we should do the slicing.

  split_index = (count % len (result) - 1 )


# this step is done to complete

  # counterclockwise circular fashion count.

  if split_index & gt; = 0 :


# slicing list

  right = result [split_index + 1 :]

  left = result [: split_index]


# list of lists

result = right + left


else :

  result = result [: len (result) - 1 ]


# print final result

  print ( "Relationship status:" , result [ 0 ])

Logout: < / p>

 Player 1 name: ANKIT Player 2 name: DEEPIKA Relationship status: Marriage