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") 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