diff --git a/2017/AUG.md b/2017/AUG.md index 0f9faa6..a0592cf 100644 --- a/2017/AUG.md +++ b/2017/AUG.md @@ -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) | ★★★★ | | | | | diff --git a/2017/AUG/AUG17/PALINGAM/PALINGAM.py b/2017/AUG/AUG17/PALINGAM/PALINGAM.py new file mode 100644 index 0000000..9651674 --- /dev/null +++ b/2017/AUG/AUG17/PALINGAM/PALINGAM.py @@ -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