Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2017/AUG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
| [AUG17](https://www.codechef.com/AUG17) | [RAINBOWA](https://www.codechef.com/AUG17/problems/RAINBOWA) | ★★ | | [![image](../img/GH.png)](AUG/AUG17/RAINBOWA/RAINBOWA.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14909134) (100 pts) [![image](../img/AC.png)](#) | [![image](../img/GH.png)](AUG/AUG17/RAINBOWA/RAINBOWA.java) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14859923) (100 pts) [![image](../img/AC.png)](#) | |
| [AUG17](https://www.codechef.com/AUG17) | [CHEFMOVR](https://www.codechef.com/AUG17/problems/CHEFMOVR) | ★★ | | | | |
| [AUG17](https://www.codechef.com/AUG17) | [GCAC](https://www.codechef.com/AUG17/problems/GCAC) | ★★★ | | [![image](../img/GH.png)](AUG/AUG17/GCAC/GCAC.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14947059) (100 pts) [![image](../img/AC.png)](#) | | |
| [AUG17](https://www.codechef.com/AUG17) | [PALINGAM](https://www.codechef.com/AUG17/problems/PALINGAM) | ★★★ | | | | |
| [AUG17](https://www.codechef.com/AUG17) | [PALINGAM](https://www.codechef.com/AUG17/problems/PALINGAM) | ★★★ | | [![image](../img/GH.png)](AUG/AUG17/PALINGAM/PALINGAM.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14908284) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](AUG/AUG17/PALINGAM/PALINGAM.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15606362) (100 pts) [![image](../img/AC.png)](#) |
| [AUG17](https://www.codechef.com/AUG17) | [CHEFFA](https://www.codechef.com/AUG17/problems/CHEFFA) | ★★★★ | | | | |
| [AUG17](https://www.codechef.com/AUG17) | [STRINGRA](https://www.codechef.com/AUG17/problems/STRINGRA) | ★★★★ | | | | |
| [AUG17](https://www.codechef.com/AUG17) | [MATDW](https://www.codechef.com/AUG17/problems/MATDW) | ★★★★ | | | | |
Expand Down
36 changes: 36 additions & 0 deletions 2017/AUG/AUG17/PALINGAM/PALINGAM.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Code Copyright: Amit Sarkar, Computer Science Engineering 2nd Year, BIT Mesra
t = input()
while (t > 0):
a = raw_input()
b = raw_input()

na = len(a)
nb = len(b)

lpa = []
lpb = []
for i in range(26):
lpa.append(0)
lpb.append(0)
k2 = ord('a')
for i in range(na):
lpa[ord(a[i]) - k2] = lpa[ord(a[i]) - k2] + 1
for i in range(nb):
lpb[ord(b[i]) - k2] = lpb[ord(b[i]) - k2] + 1
flag = 0
c1 = 0
c2 = 1
for i in range(26):
if (lpa[i] >= 2) and (lpb[i] == 0):
flag = 1
if (lpa[i] != 0) and (lpb[i] == 0):
c1 = 1
if(c1 == 1):
for i in range(26):
if (lpb[i] != 0) and (lpa[i] == 0):
c2 = 0
if (flag == 1) or ((c1 == 1) and (c2 == 1)):
print "A"
else:
print "B"
t = t-1