FLAMES Game

FLAMES Game  

Problem:

FLAMES game is a relationship calculating game. Letters in FLAMES stand for, 

F - FRIENDS 

L - LOVER 

A - AFFECTION 

M - MARRIAGE 

E - ENEMY 

S - SIBLING 

Calculation Logic - FLAMES: 

1. Get two names S1 and S2. 

2. Remove the common characters in both the names. 

3. Find the count of the characters that are left, the count is called FLAMES count FC. 

4. Consider FLAMES letters ('F', 'L', 'A', 'M', 'E', 'S') and start removing the letters in a circular manner using the FC. 

5. The letter which is finally left desides the output, 

If it's F - FRIENDS L - LOVER A - AFFECTION M - MARRIAGE E - ENEMY S - SIBLING 

Input Format: 

First line contains S1 Second line contains S2 

Output Format: 

First line contains FLAMES relationship in uppercase. 

Boundary Conditions: 

2 <= S1, S2 <= 100 

Example Input/Output 1: 

Input: 

raja 

rani 

Output: 

ENEMY 

Example Input/Output 2: 

Input: 

waffles 

bright 

Output: 

AFFECTION

Program:

s = input().strip().lower()

t = input().strip().lower()

a = list(s)

b = list(t)

for i in s: 

    if i in t:

        if i in a and i in b:

            a.remove(i)

            b.remove(i) 

leng = len(a) + len(b) 

flames = list("FLAMES")

while len(flames) > 1:

    pos = leng%len(flames)

    if pos == 0: 

        pos = len(flames)

    flames = flames[pos:] + flames[:pos-1] 

l = ["FRIENDS","LOVER","AFFECTION","MARRIAGE","ENEMY","SIBLING"] 

for i in l:

    if i[0] == flames[0]:

        print(i)

        break

Comments

Popular posts from this blog

Pronic Integers in N - InfyTQ question

Count Strong Points - Accenture

Letters at position of multiples of a number