forked from Srinivas11789/AlgorithmNuggets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabb.py
More file actions
48 lines (35 loc) · 988 Bytes
/
abb.py
File metadata and controls
48 lines (35 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Pending - 4 tcs to pass yet - hr medium
#!/bin/python
import math
import os
import random
import re
import sys
# Complete the abbreviation function below.
def abbreviation(a, b):
# First check if all the characters in A exist in B
a = list(a)
for char in b:
# Check if all the characters in b exist in a
if char.upper() in a:
del a[a.index(char.upper())]
elif char.lower() in a:
del a[a.index(char.lower())]
else:
#print char
return "NO"
# Check for the condition with the remaining characters
#print a
for char in a:
if char.isupper():
return "NO"
return "YES"
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
q = int(raw_input())
for q_itr in xrange(q):
a = raw_input()
b = raw_input()
result = abbreviation(a, b)
fptr.write(result + '\n')
fptr.close()