From 082c1e457331fce3bed6f00c8529e16942f8e2e5 Mon Sep 17 00:00:00 2001 From: Avichal Srivastava Date: Sun, 27 Feb 2022 15:49:10 +0530 Subject: [PATCH 1/2] Added Solution of Problem 1 : Avichal Srivastava --- ...vichalsrivastava242403_gameofcodes_Ps-1.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Problem Statement-1/Solution/avichalsrivastava242403_gameofcodes_Ps-1.py diff --git a/Problem Statement-1/Solution/avichalsrivastava242403_gameofcodes_Ps-1.py b/Problem Statement-1/Solution/avichalsrivastava242403_gameofcodes_Ps-1.py new file mode 100644 index 0000000..1bf2259 --- /dev/null +++ b/Problem Statement-1/Solution/avichalsrivastava242403_gameofcodes_Ps-1.py @@ -0,0 +1,20 @@ +def gcd(a,b): + if a == 0: + return b + return gcd(b % a, a) + +def lcm(a,b): + return (a / gcd(a,b))* b + +t=int(input()) +for i in range(t): + n,a,b,k = map(int, input().split()) + totala = n//a + totalb = n//b + lcmab = int(lcm(a,b)) + totallcm = n//lcmab + total = totala + totalb - 2*totallcm + if(total>=k): + print("Win") + else: + print("Lose") From 7f9bd8fd0a8ed689ee117e0d464cf12e6f8a557c Mon Sep 17 00:00:00 2001 From: Avichal Srivastava Date: Sun, 27 Feb 2022 16:14:52 +0530 Subject: [PATCH 2/2] Added Solution of Problem 2 : Avichal Srivastava --- ...vichalsrivastava242403_gameofcodes_Ps-2.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Problem Statement-2/Solution/avichalsrivastava242403_gameofcodes_Ps-2.py diff --git a/Problem Statement-2/Solution/avichalsrivastava242403_gameofcodes_Ps-2.py b/Problem Statement-2/Solution/avichalsrivastava242403_gameofcodes_Ps-2.py new file mode 100644 index 0000000..4d7747e --- /dev/null +++ b/Problem Statement-2/Solution/avichalsrivastava242403_gameofcodes_Ps-2.py @@ -0,0 +1,37 @@ +def MrRobot(string): + n = len(string) + if (n < 2): + return string + start=0 + maxLength=1 + for i in range(n): + low = i - 1 + high = i + 1 + while (high < n and string[high] == string[i] ): + high=high+1 + while (low >= 0 and string[low] == string[i] ): + low=low-1 + while (low >= 0 and high < n and string[low] == string[high]): + low=low-1 + high=high+1 + length = high - low - 1 + if (maxLength < length): + maxLength = length + start=low+1 + return string[start:start + maxLength] + +inp=input() +ct=0 +ans="" +while(1): + inp=MrRobot(inp) + if(len(inp)==1): + ans=str(ct)+" "+inp + break + if(len(inp)%2==1): + inp=inp[:len(inp)-1] + else: + inp=inp[:len(inp)//2] + ct+=1 + +print(ans) \ No newline at end of file