Skip to content
Open
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
28 changes: 28 additions & 0 deletions Problem Statement-1/Solution/Ritish04_gameofcodes_Ps-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <iostream>

using namespace std;

int main()
{
int t;
cin>>t;
while(t--){
int n,a,b,k;
cin>>n>>a>>b>>k;
int count,ans=0;
int ar[n];
for(int i=0;i<n;i++){
cin>>ar[i];
}
for(int i=0;i<n;i++){
if((ar[i]%a==0)&&(ar[i]%b!=0))count++;
else if((ar[i]%b==0) && (ar[i]%a!=0))count++;
else if((ar[i]%b==0) && (ar[i]%a==0))ans++;
}

if((count-ans)>=k)cout<<"Win"<<endl;
else cout<<"Lose"<<endl;
}

return 0;
}
43 changes: 43 additions & 0 deletions Problem Statement-2/Solution/Ritish04_gameofcodes_Ps-2
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// C++ program for the above approach
#include <bits/stdc++.h>
using namespace std;


bool isPalindrome(string S)
{

for (int i = 0; i < n / 2; i++) {



if (S[i] != S[n - i - 1]) {

return false;
}
}

return true;
}


int main()
{
int n;
cin>>n;
string S;
cin>>S;
cout << isPalindrome(S);
int depth =0;
while(n%2!=0){
if((n%2==0)&& (isPalindrome){
n=n/2;
depth++;
string s1=s;
}

}
return depth;
cout<<endl;
cout<<s1<<endl;
return 0;
}
48 changes: 48 additions & 0 deletions Problem Statement-3/Solution/Ritish04_gameofcodes_Ps-3
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <iostream>
using namespace std;
// Recursive function to return gcd of a and b
int gcd(int a, int b,int arr[])
{
// int arr[n];
// for(i=0;i<n;i++){
// cin>>arr[i];
// }
int i=0;
a=arr[i];
b=arr[i+1];
if (a == 0)
return b;
if (b == 0)
return a;

if (a == b)
return a;

if (a > b)
return gcd(a-b, b,arr);
return gcd(a, b-a,arr);
}

int main()
{
int n;
int i;
cin>>n;
int arr[n];
int count=0;
// for(i=0;i<n;i++){
// cin>>arr[i];
// }
int a,b;
for( i=0;i<n;i++){
// a=arr[i];
// b=arr[i+1];
gcd(a,b,arr);
//cout<<"GCD of "<<a<<" and "<<b<<" is "<<gcd(a,b);
}
if(gcd(a,b,arr)==1){count++;
return count;
}
return -1;

}