Answer to Question #309233 in Python for Manish

Question #309233

Friend and Enemy

A group of F friends went to a haunted house.Each member was given a shirt with a number on it ranging from 1 to F. As they entered the haunted house, one of them was kidnapped and an enemy joined them.But unfortunately, the enemy didn't wear the shirt with the same number as the kidnapped one, instead wore the same as some other person.Find the numbers on the shirts of the enemy and the kidnapped person.


Input

The input is a single line containing space-separated positive integers from 1 to F.


Output

The output should be a single line containing the shirt numbers of the enemy and kidnapped person separated by a space.


Explanation

The given array is 3 1 5 2 1.

In the range from 1 to 5, the number 1 has occured twice and 4 is the missing number. So, 1 belongs to the enemy's shirt, and 4 belongs to kidnapped.Hence, the output should be 1 4.


Sample Input1

3 1 5 2 1

Sample Output1

1 4


Sample Input2

1 2 2 4

Sample Output2

2 3


1
Expert's answer
2022-03-10T18:07:32-0500
sp = input('Enter space seperated numbers')
for i in range(1, len(sp)+1):
    if i not in sp.split(' '):
        kid = i
    elif sp.count(i):
        ene = i
print(ene, kid)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS