Given a list of different right and left foot shoes, write a python code to return the exact number of shoe pairs which can be formed from the given list. Also, return how many number of shoes of which foot are required to form pairs with the unpaired shoes.
Input Format
Input_list = ['R','L','L','R','R',R','R,'L']
Constraints
.
Output Format
Paired: 3
Unpaired: 2
Required left Shoes
Sample Input 0
8
L R L L R L R L
Sample Output 0
Paired: 3
Unpaired: 2
Required right shoes
Sample Input 1
def num_list(list1):
p = min(list1.count('R'), list1.count('L'))
r = abs(list1.count('R')- list1.count('L'))
return 'no of paired and unpaired shoes are {} and {}'.format(p,r)
num_list(['R','R','R', 'L', 'L'])
Comments
Leave a comment