├── 3. Medium ├── README.md ├── Arrays │ ├── transposeOfAMatrix │ ├── transposeOfAMatrix.cpp │ └── RainwaterTrapping.cpp ├── reverseAStringRecursion.cpp ├── reverseCodingChallenge.cpp ├── piToNDecimalPlaces.cpp ├── reverseTheStringRecursively.cpp ├── gcd.cpp ├── DoubleCharacterSwap.cpp ├── CapsToFront.cpp ├── arrayOfMultiples.cpp ├── PerfectSquarePatch.cpp ├── findTheOddInteger.cpp ├── returnCountLettersInAWordSearch.cpp ├── AnOrderedMatrix.cpp ├── NumberOfUniqueBSTs.cpp ├── isPlaindromeString.cpp └── ZigZag-Conversion.cpp ├── 4. Hard ├── README.md ├── howManyRectangles.cpp ├── oddlyOrEvenly.cpp ├── persistantLittleBugger.cpp ├── makingchange.cpp ├── lettersSharedBetweenTwoWords.cpp ├── bitsInInteger.cpp ├── nextPrime.cpp ├── checkConsecutiveNumbers.cpp ├── ReverseCodingChallenge5.cpp ├── reverse.cpp ├── findTheOddInteger.cpp ├── makingABox.cpp ├── letterDistance.cpp ├── letters.cpp ├── matrix_transpose.cpp ├── atbashCipher.cpp ├── replaceLettersWithPositionInAlphabet.cpp ├── sortByLength.cpp ├── returnMinMax.cpp ├── sharedLetters.cpp ├── daysBetweendates.cpp ├── returnTheNextPrime.cpp ├── filterPrime.cpp ├── containDuplicates.cpp ├── tallymarks.cpp └── slidingSum.cpp ├── 6. Expert ├── README.md ├── waterjugProb │ ├── Main.cpp │ └── waterjugProb.h ├── primeFactorsWithSum.cpp ├── phoneLetterCombinationAlternative.cpp ├── PhoneLetterCombination.cpp └── rollTheDice.cpp ├── 5. Very Hard ├── README.md ├── split25.cpp ├── nextLargestNumber.cpp ├── primeFactorizationOfAnInteger.cpp ├── productOfDigitsOfSum.cpp ├── hexToBinaryUsingLoops.cpp ├── persistence.cpp ├── caesarsCipher.cpp ├── hexToBinary.cpp └── SupperEggDrop.cpp ├── 2.Easy ├── README.md ├── absolute_sum.cpp ├── numberSquares.cpp ├── addUp.cpp ├── powerCalculator.cpp ├── gcd.cpp ├── printBurrrp.cpp ├── recursiveFibonacciNumbers.cpp ├── equalityOfThree.cpp ├── returnAgeToDays.cpp ├── profitableGamble.cpp ├── alphabetSoup.cpp ├── countSyllable.cpp ├── maskifyString.cpp ├── brokenBridges.cpp ├── staircaseOfRecursion.cpp ├── reverseStringOrder.cpp ├── CountInstancesOfACharacterInAString.cpp ├── eliminateOddValues.cpp ├── largestSwap.cpp ├── evenOrOddNumberOfFactors.cpp ├── convertNumberToBase2.cpp ├── findTheMissingNumber.cpp ├── middleCharOfString.cpp ├── hittingTheJackpot.cpp ├── mysteryChallenge.cpp ├── HowManyVowels.cpp └── sumOfCubes.cpp ├── 1. Very Easy ├── XORSwap.cpp ├── oddEven.cpp ├── 2Sum.cpp ├── returnConvert.cpp ├── circuitPower.cpp ├── equalSlices.cpp ├── returnAreaOfTriangle.cpp ├── returnHelloName.cpp ├── nameGreeting!.cpp ├── areaOfTriangle.cpp ├── lessThan100.cpp ├── returnTheNextNumber.cpp ├── powerCalculator.cpp ├── returnLessOrEqualToZero.cpp ├── rootOfQuadraticEquation.cpp ├── divisibleBy100.cpp ├── functionDerivative.cpp ├── returnTheLastElementOfAnArray.cpp ├── maximumEdgeOfATriangle.cpp ├── isTheNumberLessThanOrEqualToZero.cpp ├── sumOfTwoNumbers.cpp ├── Returnadditionoftwonumber.cpp ├── animals.cpp └── timeForMilkAndCookies.cpp ├── .gitignore ├── .github ├── PULL_REQUEST_TEMPLATE.md ├── workflows │ └── close_inactive_issue.yaml └── ISSUE_TEMPLATE │ └── new-issue-for-adding-probem.md ├── README.md ├── LICENSE ├── CONTRIBUTING.md └── CODE_OF_CONDUCT.md /3. Medium/README.md: -------------------------------------------------------------------------------- 1 | # Edabit-Solutions 2 | Edabit Solutions using Cpp 3 | -------------------------------------------------------------------------------- /4. Hard/README.md: -------------------------------------------------------------------------------- 1 | # Edabit-Solutions 2 | Edabit Solutions using Cpp 3 | -------------------------------------------------------------------------------- /6. Expert/README.md: -------------------------------------------------------------------------------- 1 | # Edabit-Solutions 2 | Edabit Solutions using Cpp 3 | -------------------------------------------------------------------------------- /5. Very Hard/README.md: -------------------------------------------------------------------------------- 1 | # Edabit-Solutions 2 | Edabit Solutions using Cpp 3 | -------------------------------------------------------------------------------- /2.Easy/README.md: -------------------------------------------------------------------------------- 1 | # Edabit-Solutions 2 | Edabit Solutions using Cpp under Easy category 3 | -------------------------------------------------------------------------------- /3. Medium/Arrays/transposeOfAMatrix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aayushi-droid/Edabit-Solutions/HEAD/3. Medium/Arrays/transposeOfAMatrix -------------------------------------------------------------------------------- /1. Very Easy/XORSwap.cpp: -------------------------------------------------------------------------------- 1 | //Problem statement : Switch 2 variables using the XOR operator 2 | //Probelm Link : https://edabit.com/challenge/dHYXiEXydZxrwntBq 3 | #include 4 | std::pair XOR(int a, int b) { 5 | a^=b; 6 | b^=a; 7 | a^=b; 8 | return std::make_pair(a,b); 9 | } -------------------------------------------------------------------------------- /2.Easy/absolute_sum.cpp: -------------------------------------------------------------------------------- 1 | #include "bits/stdc++.h" 2 | using namespace std; 3 | 4 | int getAbsSum(std::vector arr) { 5 | int x=0; 6 | for (int y:arr) 7 | { 8 | x+= abs(y); 9 | } 10 | return x; 11 | } 12 | 13 | int main() 14 | { 15 | vector arr {2, -1, 4, 8, 10}; 16 | cout << getAbsSum(arr) << endl; 17 | return 0; 18 | } -------------------------------------------------------------------------------- /4. Hard/howManyRectangles.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : How many rectangles are there in a square matrix 2 | * Problem Link : https://edabit.com/challenge/EePutMiQcitWdEA5s 3 | */ 4 | 5 | #include 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | double step; 11 | cin>>step; 12 | double tri=(step*(step+1))/2; 13 | cout< 7 | using namespace std; 8 | 9 | string isEvenOrOdd(int number){ 10 | return (number%2==0)?"even":"odd"; 11 | } 12 | 13 | int main(){ 14 | int number; 15 | cin>>number; 16 | cout< 5 | using namespace std; 6 | 7 | int number_squares(int n) 8 | { 9 | return (n*(n+1)*(2*n+1))/6; 10 | } 11 | 12 | int main() 13 | { 14 | int num; 15 | cin >> num; 16 | 17 | cout << number_squares(num); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /1. Very Easy/2Sum.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : This program will add two numbers 2 | * Problem Link : https://edabit.com/challenge/SFzHtm63XT6EYNHWY 3 | */ 4 | 5 | #include 6 | using namespace std; 7 | 8 | int addition(int a, int b) { 9 | return a + b; 10 | } 11 | 12 | int main() { 13 | int a, b, sum; 14 | cin >> a; 15 | cin >> b; 16 | sum = addition(a,b); 17 | cout << sum; 18 | return 0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /2.Easy/addUp.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task :Add up the Numbers from a Single Number 2 | * Problem Link : https://edabit.com/challenge/XDx6JoaumAimRHgEt 3 | */ 4 | 5 | #include 6 | using namespace std; 7 | 8 | int addUp(int N) 9 | { 10 | int sum=0; 11 | for(int i=1; i<=N;i++) 12 | sum+=i; 13 | return sum; 14 | } 15 | 16 | 17 | int main() 18 | { 19 | int N; 20 | cin>>N; 21 | 22 | cout< 7 | #include 8 | 9 | using namespace std; 10 | 11 | int convert(int minutes) 12 | { 13 | return 60*minutes; 14 | } 15 | 16 | int main() 17 | { 18 | int minutes; 19 | cin>>minutes; 20 | cout< 7 | using namespace std; 8 | 9 | int circuitPower(int voltage, int current) 10 | { 11 | return voltage*current; 12 | } 13 | 14 | int main() 15 | { 16 | int voltage, current; 17 | cin>>voltage>>current; 18 | cout< 7 | using namespace std; 8 | 9 | bool equalSlices(int total, int people, int each) 10 | { 11 | return people*each<=total; 12 | } 13 | 14 | int main() 15 | { 16 | int total, people, each; 17 | cin>>total>>people>>each; 18 | cout< 6 | using namespace std; 7 | 8 | double powerCalculator(double voltage, double current) { 9 | 10 | return voltage * current; 11 | 12 | } 13 | 14 | int main() { 15 | double voltage, current; 16 | cin >> voltage >> current; 17 | 18 | cout << powerCalculator(voltage, current); 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /3. Medium/reverseAStringRecursion.cpp: -------------------------------------------------------------------------------- 1 | //Recursion: Reverse a String 2 | //Problem Statement - Write a function that reverses a string. Make your function recursive. 3 | // Link - https://edabit.com/challenge/HXGx9oXukEgsFK6PH 4 | #include 5 | #include 6 | using namespace std; 7 | string reverse(string str) { 8 | if(str.length()<=1) 9 | return str; 10 | string smallAns=reverse(str.substr(1,str.length()-1)); 11 | return smallAns+str.at(0); 12 | } 13 | -------------------------------------------------------------------------------- /1. Very Easy/returnAreaOfTriangle.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Problem Task: This program will return the area of a triangle 3 | Problem Link: https://edabit.com/challenge/HvYiBXgfPtnDHitym 4 | */ 5 | 6 | #include 7 | using namespace std; 8 | 9 | double areaOfTriangle(double b, double h) { 10 | return ((b * h) / 2); 11 | }; 12 | 13 | int main() { 14 | double base, height; 15 | cin >> base >> height; 16 | cout << areaOfTriangle(base, height) << endl; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /1. Very Easy/returnHelloName.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : Create a function that takes a name and returns a greeting in the form of a string. 2 | * Problem Link : https://edabit.com/challenge/MtG39AgXhyeePSiY2 3 | */ 4 | 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | string helloName(string name){ 10 | return "Hello " + name + "!"; 11 | } 12 | 13 | int main(){ 14 | string S; 15 | cin >> S; 16 | cout << helloName(S); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /2.Easy/gcd.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* Problem-Task : Write a function that returns the greatest common divisor (GCD) of two integers. 3 | * Problem Link : https://edabit.com/challenge/6g5Nj6Qz44Sd2NbBQ 4 | */ 5 | 6 | #include 7 | using namespace std; 8 | 9 | int gcd(int n1, int n2) { 10 | while(n1!=n2){ 11 | if(n1>n2) n1-=n2; 12 | else n2-=n1; 13 | } 14 | return n1; 15 | } 16 | 17 | int main(){ 18 | cout< 5 | using namespace std; 6 | 7 | string helloName(string name){ 8 | return "Hello " + name + "!"; 9 | } 10 | 11 | int main(){ 12 | string name; 13 | cin>>name; 14 | cout << helloName(name); 15 | //helloName("Ed") ➞ "Hello Ed!" 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | enter here if you have any details 4 | 5 | **Program Name** - 6 | **Issue No.**- # 7 | > Type issue number after hash(#) 8 | 9 | ## Checklist(self check) 10 | 11 | - [ ] Yes, this task assigned to me. 12 | - [ ] My code follows the style guidelines(Clean Code) of this project 13 | - [ ] I have performed a self-review of my own code 14 | - [ ] My Filename is in camelCase format 15 | - [ ] I have added **Problem statement**, **Problem link** in file. 16 | -------------------------------------------------------------------------------- /1. Very Easy/areaOfTriangle.cpp: -------------------------------------------------------------------------------- 1 | //Problem statement :Area of Triangle 2 | //Probelm Link : https://edabit.com/challenge/HvYiBXgfPtnDHitym 3 | //Choose one Cateorgy - Very Easy, Easy, Medium, Hard, Very Hard, Expert 4 | //question category : Very Easy 5 | 6 | #include 7 | using namespace std; 8 | 9 | int main() 10 | { 11 | float base,height; 12 | cout<<"Enter Base\n"; cin>>base; 13 | cout<<"Enter Height\n"; cin>>height; 14 | cout<<"Area of Triangle is\n "<<0.5*base*height; 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /1. Very Easy/lessThan100.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Problem Name : Less Than 100? 3 | Problem Link : https://edabit.com/challenge/9MjEpkL7yAjAqiH58 4 | */ 5 | 6 | #include 7 | using namespace std; 8 | 9 | bool lessThan100(int num1, int num2){ 10 | return (num1 + num2 < 100)?true:false; 11 | } 12 | 13 | int main(){ 14 | int num1, num2; 15 | cin >> num1 >> num2; 16 | if(lessThan100(num1, num2)) 17 | cout << "true"; 18 | else 19 | cout << "false"; 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /1. Very Easy/returnTheNextNumber.cpp: -------------------------------------------------------------------------------- 1 | /* this program will return next number 2 | * Problem statement : Create a function that takes a number as an argument, 3 | * add one to the number, and return the result. 4 | * https://edabit.com/challenge/QgCMMMyMmckvHbfKv 5 | */ 6 | 7 | #include 8 | using namespace std; 9 | 10 | int addition(int n) { 11 | return n + 1; 12 | } 13 | 14 | int main() { 15 | int number; 16 | cin>>number; 17 | cout << addition(number) << endl; 18 | } 19 | -------------------------------------------------------------------------------- /1. Very Easy/powerCalculator.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-name : Power Calculator 2 | Problem-task : Create a function that takes voltage and current and returns the calculated power. 3 | Problem-Link : https://edabit.com/challenge/a2D3cva6PKrHyqdXC 4 | */ 5 | 6 | #include 7 | 8 | using namespace std; 9 | 10 | int circuitPower(int v,int c) 11 | { 12 | return (v * c); 13 | } 14 | 15 | int main() 16 | { 17 | int pow,volt,curr; 18 | cin>>volt>>curr; 19 | pow = circuitPower(volt, curr); 20 | cout< 7 | using namespace std; 8 | 9 | int longBurp(int num) { 10 | string r; 11 | for (int i=0;i> num; 23 | longBurp(num); 24 | 25 | return 0; 26 | } -------------------------------------------------------------------------------- /1. Very Easy/returnLessOrEqualToZero.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Problem Task: This program will return whether a given number is less than or equal to zero 3 | Problem Link: https://edabit.com/challenge/7KFAJSSp3pmE8bHhK 4 | */ 5 | 6 | #include 7 | using namespace std; 8 | 9 | bool lessThanOrEqualToZero(int a) { 10 | return (a <= 0); 11 | }; 12 | 13 | int main() { 14 | int num; 15 | cin >> num; 16 | if(lessThanOrEqualToZero(num)){ 17 | cout<<"True"; 18 | } 19 | else{ 20 | cout<<"False"; 21 | } 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /4. Hard/oddlyOrEvenly.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | void position(string str){ 6 | for(int i=0; i 2 | #include 3 | 4 | using namespace std; 5 | // This program will find only the root value of quadratic equation. 6 | // problem: https://edabit.com/challenge/nasKYub6qEAfQcFuy 7 | 8 | int root(int a,int b,int c) 9 | { 10 | int root= (-b+sqrt(b*b-4*a*c))/(2*a); 11 | return root; 12 | } 13 | // a(x^2)+bx+c is the quadratic equation 14 | int main() 15 | { 16 | int a,b,c; 17 | cin>>a>>b>>c; 18 | 19 | int ans= root(a,b,c); 20 | cout< 5 | using namespace std; 6 | 7 | string divisible(int number) 8 | { 9 | if (number % 100 == 0) 10 | return "true"; 11 | else 12 | return "false"; 13 | } 14 | 15 | int main() 16 | { 17 | 18 | cout << divisible(1000); 19 | //divisible(1000) ➞ true 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /1. Very Easy/functionDerivative.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : Create a function that takes numbers b and m as arguments and returns the derivative of the function f(x)=x^b with respect to x at the point where x=m, where band m are constants. 2 | * Problem Link : https://edabit.com/challenge/sR3aNNQ9kJoSurDLK 3 | */ 4 | 5 | #include 6 | using namespace std; 7 | 8 | int derivative(int b, int m) { 9 | return b*pow(m, b-1); 10 | } 11 | 12 | int main() { 13 | int b, m; 14 | cin>>b>>m; 15 | cout< 7 | using namespace std; 8 | 9 | int getLastItem(int A[], int N) 10 | { 11 | return A[N - 1]; 12 | } 13 | int main() 14 | { 15 | int Array[] = {1, 5, 6, 8, 2, 4, 5}; 16 | int Size = 7; 17 | cout << getLastItem(Array, Size); 18 | } -------------------------------------------------------------------------------- /2.Easy/recursiveFibonacciNumbers.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : This program will recursively calculate the nth given number in Fibonacci's sequence 2 | * Problem Link : https://edabit.com/challenge/SFzHtm63XT6EYNHWY 3 | */ 4 | 5 | #include 6 | 7 | int fibonacci(unsigned int n); 8 | 9 | int fibonacci(unsigned int n) { 10 | 11 | if(n == 0 || n == 1) 12 | return n; 13 | 14 | else 15 | return (fibonacci(n-1) + fibonacci(n-2)); 16 | 17 | } 18 | 19 | int main() { 20 | int n = 8; 21 | 22 | std::cout << fibonacci(n); 23 | 24 | return 0; 25 | } -------------------------------------------------------------------------------- /2.Easy/equalityOfThree.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Problem Task: This program will return how many numbers are equal. 3 | Problem Link: https://edabit.com/challenge/wujqD4xbL7X5Bzd5e 4 | */ 5 | 6 | #include 7 | using namespace std; 8 | 9 | int equal(int a, int b, int c) { 10 | if (a==b && b==c && c==a) { 11 | return 3; 12 | } else if (a!=b && b!=c && c!=a) { 13 | return 0; 14 | } else { 15 | return 2 16 | } 17 | }; 18 | 19 | int main() { 20 | 21 | int a, b, c; 22 | 23 | cin >> a >> b >> c; 24 | cout << equal(a, b, c); 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /2.Easy/returnAgeToDays.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Problem task : convert age to days 3 | Problem Link: https://edabit.com/challenge/bL7hSc6Zh4zZJzGmw 4 | */ 5 | 6 | #include 7 | using namespace std; 8 | 9 | int calcage(int age) { 10 | //in one year there are 365 days as problem said to ignore the leap year 11 | int days=age*365; 12 | return days; 13 | } 14 | 15 | int main() { 16 | int age; 17 | cout<<"enter the age"; 18 | cin>>age; 19 | //we have to convert the age in no. of days 20 | int days=calcage(age); 21 | cout< 6 | using namespace std; 7 | 8 | int mysteryFunc(int num) { 9 | std::string temp = std::to_string(num); 10 | std::sort(temp.begin(), temp.end()); 11 | return abs(num - stoi(temp)); 12 | } 13 | 14 | int main() { 15 | int num; 16 | cin>>num; 17 | cout< 9 | using namespace std; 10 | 11 | int nextEdge(int side1, int side2){ 12 | return (side1 + side2) - 1; 13 | }; 14 | 15 | int main(){ 16 | int side1, side2; 17 | cin >> side1; 18 | cin >> side2; 19 | cout << nextEdge(side1, side2) << endl; 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /2.Easy/profitableGamble.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Problem task : Create a function that takes three arguments prob, prize, pay and returns true if prob * prize > pay; 3 | otherwise return false. 4 | Problem Link : https://edabit.com/challenge/KWHHhfYMDEEvASK6G 5 | */ 6 | 7 | #include 8 | using namespace std; 9 | 10 | int profitableGamble(float prob, int prize, float pay) { 11 | if(prob * prize > pay ) { 12 | cout << "true"; 13 | }else{ 14 | cout << "false"; 15 | } 16 | } 17 | 18 | int main() { 19 | profitableGamble(0.2, 50, 9); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /1. Very Easy/isTheNumberLessThanOrEqualToZero.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Problem Name : Is the Number Less than or Equal to Zero? 3 | Problem Link : https://edabit.com/challenge/7KFAJSSp3pmE8bHhK 4 | */ 5 | #include 6 | using namespace std; 7 | 8 | bool numLessThanOrEqualZero(int num) 9 | { 10 | if(num <= 0) 11 | return true; 12 | else 13 | return false; 14 | } 15 | 16 | int main() 17 | { 18 | int num; 19 | cin >> num; 20 | if(numLessThanOrEqualZero(num)) 21 | cout << "true \n"; 22 | else 23 | cout << "false \n"; 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /2.Easy/alphabetSoup.cpp: -------------------------------------------------------------------------------- 1 | // problem statement:Create a function that takes a string 2 | // and returns a string with its letters in alphabetical 3 | // order. 4 | //link:https://edabit.com/challenge/KNxEs8se6jzyHDBfy 5 | 6 | #include 7 | using namespace std; 8 | 9 | // function to print string in sorted order 10 | void alphabetSoup(string &str){ 11 | sort(str.begin(), str.end()); 12 | cout << str; 13 | } 14 | 15 | // Driver program to test above function 16 | int main(){ 17 | string s; 18 | cin>>s; 19 | alphabetSoup(s); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /3. Medium/piToNDecimalPlaces.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Problem-Task : This program will display to n number og decimal places of PI. 3 | Problem-Link : https://edabit.com/challenge/wzPBMkanx2Db8Kpmp 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | 11 | double myPi(int n) 12 | { 13 | return round(M_PI * pow(10, n)) / pow(10, n); 14 | } 15 | 16 | int main() 17 | { 18 | int n; 19 | double piVal; 20 | cout << "Enter number of decimal places to which PI will be displayed : "; 21 | cin >> n; 22 | piVal = myPi(n); 23 | cout << "PI : " << piVal; 24 | } -------------------------------------------------------------------------------- /2.Easy/countSyllable.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Problem-Task: Create a function that counts the number of syllables a word has. Each syllable is separated with a dash -. 3 | Problem Link: https://edabit.com/challenge/zRe5fx3MbiBxcrvXH 4 | */ 5 | #include 6 | using namespace std; 7 | 8 | int numberSyllables(std::string word) { 9 | int count = 0; 10 | for(int i=0;i 6 | #include 7 | using namespace std; 8 | 9 | void maskify(string a) 10 | { 11 | int l = a.length(); 12 | for (int i = 0; i < l - 4; i++) 13 | { 14 | a[i] = '#'; 15 | } 16 | cout << a; 17 | } 18 | 19 | int main() 20 | { 21 | string l; 22 | cout << "Enter a string you need to mask : "; 23 | cin >> l; 24 | cout << "\nNew Masked String is : "; 25 | maskify(l); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /3. Medium/reverseTheStringRecursively.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : This program will reverse the string recursively 2 | * Problem Link : https://edabit.com/challenge/HXGx9oXukEgsFK6PH 3 | * */ 4 | 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | void reverse(std::string &str,int i=0){ 11 | int n=str.length(); 12 | if(i==n/2){ 13 | return; 14 | } 15 | std::swap(str[i],str[n-i-1]); 16 | reverse(str,i+1); 17 | 18 | } 19 | 20 | int main(){ 21 | std::string str="Hello World"; 22 | reverse(str); 23 | std::cout< 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | int num; 11 | cin>>num; 12 | int cnt=0; 13 | while(num>9) 14 | { 15 | int temp=num; 16 | vector v; 17 | while(temp!=0) 18 | { 19 | v.push_back(temp%10); 20 | temp/=10; 21 | } 22 | num=1; 23 | for(int i=0;i 4 | using namespace std; 5 | int gcd(int a, int b){ 6 | if(a==0){ 7 | return b; 8 | } 9 | if(b==0){ 10 | return a; 11 | } 12 | if(a==b){ 13 | return a; 14 | } 15 | if(a>b){ 16 | return gcd(a-b,b); 17 | } 18 | return gcd(a,b-a); 19 | } 20 | int main() 21 | { 22 | int a, b; 23 | cin >> a >> b; 24 | cout << gcd(a, b) << endl; 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /2.Easy/brokenBridges.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Problem-Task: Create a function which validates whether a bridge is safe to walk on (i.e. has no gaps in it to fall through). 3 | Problem Link: https://edabit.com/challenge/udrQ2ckXP9cXNXiSk 4 | */ 5 | 6 | #include 7 | using namespace std; 8 | 9 | bool isSafeBridge(std::string s) { 10 | if(s.length() == 0) 11 | return false; 12 | for(int i=0;i 7 | using namespace std; 8 | 9 | int countWays(int n){ 10 | 11 | if(n == 1 or n == 2) 12 | return n; 13 | 14 | return countWays(n-1) + countWays(n-2); 15 | 16 | } 17 | 18 | 19 | int main(){ 20 | 21 | int n; 22 | cin >> n; 23 | cout << countWays(n) << endl; 24 | 25 | return 0; 26 | } -------------------------------------------------------------------------------- /6. Expert/waterjugProb/Main.cpp: -------------------------------------------------------------------------------- 1 | // #include 2 | #include 3 | #include"waterjugProb.h" 4 | using namespace std; 5 | 6 | void printPath(std::list states) 7 | { 8 | for(auto state:states) 9 | std::cout << state.x << " " << state.y << " " << state.z << '\n'; 10 | } 11 | 12 | int main() 13 | { 14 | States s1{3, 5, 8},s2{0, 3, 5}; 15 | // States s1{4, 17, 22},s2{2, 5, 15}; 16 | 17 | auto MinOperations = waterjug(s1,s2); 18 | if(MinOperations) 19 | std::cout << MinOperations << '\n'; 20 | else 21 | std::cout << "No solution.\n"; 22 | 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /1. Very Easy/sumOfTwoNumbers.cpp: -------------------------------------------------------------------------------- 1 | /* this program will add two numbers 2 | * Problem : https://edabit.com/challenge/SFzHtm63XT6EYNHWY 3 | */ 4 | #include 5 | using namespace std; 6 | 7 | int addition(int a, int b) { 8 | if (b > 0) { 9 | while (b > 0) { 10 | a++; 11 | b--; 12 | } 13 | } 14 | if (b < 0) { // when 'b' is negative 15 | while (b < 0) { 16 | a--; 17 | b++; 18 | } 19 | } 20 | } 21 | int main() { 22 | int num1,num2; 23 | cin>>num1>>num2; 24 | cout << addition(num1, num2) << endl; 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /2.Easy/reverseStringOrder.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : Create a function that takes a string as its argument and returns the string in reversed order. 2 | * Problem Link : https://edabit.com/challenge/gYxDahmv8CbWmiThc 3 | */ 4 | #include "bits/stdc++.h" 5 | using namespace std; 6 | 7 | std::string reverse(std::string str) { 8 | int i = 0; 9 | int j = str.length() - 1; 10 | while(i 5 | using namespace std; 6 | 7 | string doubleSwap(string s, char c1, char c2) { 8 | for (int i = 0; i < s.length(); i++) { 9 | if (s[i] == c1) { 10 | s[i] = c2; 11 | } 12 | else if (s[i] == c2) { 13 | s[i] = c1; 14 | } 15 | } 16 | return s; 17 | } 18 | 19 | int main() { 20 | string s; 21 | cin >> s; 22 | char c1, c2; 23 | cin >> c1 >> c2; 24 | cout << doubleSwap(s, c1, c2); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /2.Easy/CountInstancesOfACharacterInAString.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Problem Task: Count Instances of a Character in a String 3 | Problem Link: https://edabit.com/challenge/kbFhwaDyrd79JrgeB 4 | */ 5 | 6 | #include 7 | using namespace std; 8 | 9 | int instancesOfACharacter(string str1, string str2){ 10 | char ch = str1[0]; 11 | int count = 0; 12 | for(int i = 0; i < str2.size(); i++){ 13 | if(str2[i] == ch) 14 | count++; 15 | } 16 | return count; 17 | } 18 | 19 | int main(){ 20 | string str1, str2; 21 | cin >> str1; 22 | getline(cin, str2); 23 | cout << instancesOfACharacter(str1, str2); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /5. Very Hard/split25.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : Split 25. Split numbers for maximum product 2 | * Problem Link : https://edabit.com/challenge/PbtMHCLm83NwqSnnS 3 | */ 4 | 5 | #include 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | int num; 11 | cin>>num; 12 | if(num<=4) cout< 7 | 8 | using namespace std; 9 | vector noOdds(std::vector arr) { 10 | vector result; 11 | for(int i=0;i arr = {1,2,3,4,5,6,7,8}; 21 | vector result = noOdds(arr); 22 | for(auto num : result){ 23 | if(num % 2 != 0) 24 | return -1; 25 | } 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /4. Hard/makingchange.cpp: -------------------------------------------------------------------------------- 1 | //Change Making Problem – Dynamic Programming 2 | 3 | #include 4 | using namespace std; 5 | 6 | int minCoins(int coins[], int m, int N) 7 | { 8 | if (N == 0) 9 | return 0; 10 | int result = INT_MAX; 11 | for (int i=0; i 8 | #include 9 | #include 10 | std::string capToFront(std::string str) { 11 | std::string a = ""; 12 | std::string b = ""; 13 | 14 | for (int i = 0; i < str.length(); i++) 15 | { 16 | if (isupper(str[i])) 17 | a = a + str[i]; 18 | else 19 | b = b + str[i]; 20 | } 21 | return a + b; 22 | } 23 | 24 | int main(){ 25 | std::string s; 26 | std::cin>>s; 27 | std::cout< 5 | #include 6 | using namespace std; 7 | 8 | vectorarr; 9 | 10 | void arrayOfMultiples(int number , int length) 11 | { 12 | for(int i=number ; i <= number*length ; i = i + number) 13 | { 14 | arr.push_back(i); 15 | } 16 | } 17 | 18 | int main() 19 | { 20 | int number,length; 21 | cin >> number >> length; 22 | 23 | arrayOfMultiples(number,length); 24 | 25 | for(int i = 0;i < arr.size() ; i++) 26 | { 27 | cout << arr[i] << " "; 28 | } 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /4. Hard/lettersSharedBetweenTwoWords.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Statement : Create a function that returns the number of characters shared between two words. 2 | * Problem Link : https://edabit.com/challenge/qeCS48GXtK9NJLc9C 3 | */ 4 | 5 | #include 6 | using namespace std; 7 | 8 | int sharedLetters(std::string str1, std::string str2) { 9 | int arr[26]={0}; 10 | for(auto x:str1) 11 | arr[x-'a']++; 12 | int count=0; 13 | for(auto x:str2) { 14 | if(arr[x-'a']) { 15 | count++; 16 | arr[x-'a']--; 17 | } 18 | } 19 | return count; 20 | } 21 | 22 | int main() { 23 | string str1,str2; 24 | cin>>str1>>str2; 25 | cout< 5 | using namespace std; 6 | 7 | bool largestSwap(int num) 8 | { 9 | int rev = 0, d; 10 | int dup = num; 11 | while (num > 0) 12 | { 13 | d = num % 10; 14 | num /= 10; 15 | rev = rev * 10 + d; 16 | } 17 | if (dup >= rev) 18 | return true; 19 | else 20 | return false; 21 | } 22 | 23 | int main() 24 | { 25 | int num; 26 | cin >> num; 27 | 28 | cout << largestSwap(num); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /4. Hard/bitsInInteger.cpp: -------------------------------------------------------------------------------- 1 | // C++ program to Count number of ones in binary 2 | // repersentation of a number 3 | #include 4 | using namespace std; 5 | 6 | /* Function to get no of set ones in binary 7 | representation of positive integer n */ 8 | int countSetOnes(int n) { 9 | if(n==0){ 10 | return 0; 11 | } 12 | return 1+countSetOnes(n & (n-1)); 13 | } 14 | 15 | /* Program to test function countSetOnes */ 16 | int main() { 17 | int i; 18 | cout<<"Enter the number"; 19 | cin>>i; 20 | cout <<"Number of Ones in the binary repersentation of the given number is : "< 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | int num; 11 | cin>>num; 12 | string s; 13 | int temp=num; 14 | while(temp!=0) 15 | { 16 | s.push_back(temp%10+'0'); 17 | temp/=10; 18 | } 19 | sort(s.begin(),s.end()); 20 | int ans=INT_MAX; 21 | do 22 | { 23 | int temp=stoi(s); 24 | if(temp>num) 25 | { 26 | ans=min(ans,temp); 27 | } 28 | } 29 | while(next_permutation(s.begin(),s.end())); 30 | if(ans==INT_MAX) ans=num; 31 | cout< 5 | using namespace std; 6 | 7 | char *factor_group(int n) 8 | { 9 | int i, c = 0; 10 | for (i = 1; i <= n; ++i) 11 | if (n % i == 0) 12 | c++; 13 | if (c % 2 == 0) 14 | return "even"; 15 | return "odd"; 16 | } 17 | 18 | int main() 19 | { 20 | cout << factor_group(33) << endl; 21 | //factor_group(33) ➞ "even" 22 | cout << factor_group(36) << endl; 23 | //factor_group(36) ➞ "odd" 24 | return 0; 25 | } -------------------------------------------------------------------------------- /3. Medium/PerfectSquarePatch.cpp: -------------------------------------------------------------------------------- 1 | // Problem Statement - Create a function that takes an integer and outputs an n x n square solely consisting of the integer n. 2 | // Link - https://edabit.com/challenge/omTRzwvBibk4etBkx 3 | 4 | #include 5 | using namespace std; 6 | 7 | void squarePatch(vector> &ans, int n) { 8 | if (n==0) return; 9 | for (int i = 0; i < n; i++) { 10 | ans.push_back(vector (n, n)); 11 | } 12 | } 13 | 14 | int main() { 15 | int n; cin>>n; 16 | vector> ans; 17 | squarePatch(ans, n); 18 | for (int i=0; i 8 | using namespace std; 9 | 10 | int findOdd(vector ar) { 11 | int ans = 0; 12 | for(int i=0; i ar; 21 | cout << "Enter number of integers in the array: "; 22 | cin >> n; 23 | for(int i=0; i> x; 26 | ar.push_back(x); 27 | } 28 | cout << findOdd(ar) << endl; 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /1. Very Easy/Returnadditionoftwonumber.cpp: -------------------------------------------------------------------------------- 1 | /* Problem statement : Create a function that takes two numbers as arguments and return their sum. 2 | Probelm Link : https://edabit.com/challenge/SFzHtm63XT6EYNHWY */ 3 | 4 | #include 5 | using namespace std; 6 | 7 | int addition(int a, int b) 8 | { 9 | return (a+b); //return the value of a+b 10 | } 11 | 12 | int main() 13 | { 14 | system("cls"); 15 | int a,b; 16 | cin>>a>>b; //getting the value of a and b from the user 17 | int sum = addition (a,b); //setting sum as the value returned by the function 18 | cout< 6 | using namespace std; 7 | 8 | bool isPrime(int no){ 9 | for(int i = 2;i*i<=no;i++){ 10 | if(no%i==0){ 11 | return false; 12 | } 13 | } 14 | return true; 15 | } 16 | 17 | int main(){ 18 | int n; 19 | cin>>n; 20 | if(n<=1){ 21 | cout<<2< 7 | using namespace std; 8 | 9 | bool consecutive(priority_queue pq){ 10 | int start=pq.top(); 11 | pq.pop(); 12 | while(!pq.empty()){ 13 | if(start-1!=pq.top()){ 14 | return false; 15 | } 16 | start--; 17 | pq.pop(); 18 | } 19 | return true; 20 | } 21 | 22 | 23 | int main(){ 24 | int n; 25 | cin>>n; 26 | priority_queue pq; 27 | for(int i=0;i>x; 30 | pq.push(x); 31 | } 32 | if(consecutive(pq)){ 33 | cout<<"True"; 34 | } 35 | else{ 36 | cout<<"False"; 37 | } 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /2.Easy/convertNumberToBase2.cpp: -------------------------------------------------------------------------------- 1 | Poblem statement:Create a function that returns a base-2 (binary) representation of a base-10 (decimal) string number. 2 | To convert is simple: ((2) means base-2 and (10) means base-10) 010101001(2) = 1 + 8 + 32 + 128. 3 | 4 | problem link:https: //edabit.com/challenge/3kcrnpHk7krNZdnKK 5 | 6 | #include 7 | using namespace std; 8 | 9 | // Function that convert Decimal to binary 10 | int decToBinary(long long int n) 11 | { 12 | 13 | for (long long int i = 31 ; i >= 0; i--) { 14 | long long int k = n >> i; 15 | if (k & 1) 16 | cout << "1"; 17 | else 18 | cout << "0"; 19 | } 20 | } 21 | 22 | 23 | int main() 24 | { 25 | long long int n; 26 | cin>>n; 27 | decToBinary(n); 28 | } 29 | -------------------------------------------------------------------------------- /4. Hard/ReverseCodingChallenge5.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : This program solved Reverse Coding Challenge 5 problem 2 | * Problem Link : https://edabit.com/challenge/64CeZWx5wWhTxhHLL 3 | */ 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | int sortDigitdAndMakeNumber(int num){ 10 | int sz = 0, res = 0; 11 | int a[11]; 12 | while (num){ 13 | a[sz ++] = num % 10; 14 | num /= 10; 15 | } 16 | sort(a, a + sz); 17 | for (int i = 0; i < sz; i ++) 18 | res = res * 10 + a[i]; 19 | return res; 20 | } 21 | int mysteryFunc(int num) { 22 | return num - sortDigitdAndMakeNumber(num); 23 | } 24 | 25 | int main(){ 26 | cout << mysteryFunc(832) << '\n'; 27 | cout << mysteryFunc(51) << '\n'; 28 | cout << mysteryFunc(7977) << '\n'; 29 | cout << mysteryFunc(1) << '\n'; 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /.github/workflows/close_inactive_issue.yaml: -------------------------------------------------------------------------------- 1 | name: Close inactive issues 2 | on: 3 | schedule: 4 | - cron: "0 1 * * *" 5 | 6 | jobs: 7 | close-issues: 8 | runs-on: ubuntu-latest 9 | permissions: 10 | issues: write 11 | pull-requests: write 12 | steps: 13 | - uses: actions/stale@v4 14 | with: 15 | days-before-issue-stale: 30 16 | days-before-issue-close: 14 17 | stale-issue-label: "stale" 18 | stale-issue-message: "This issue is stale because it has been open for 30 days with no activity." 19 | close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale." 20 | days-before-pr-stale: -1 21 | days-before-pr-close: -1 22 | repo-token: ${{ secrets.GITHUB_TOKEN }} 23 | -------------------------------------------------------------------------------- /3. Medium/returnCountLettersInAWordSearch.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Statement : Create a function that counts the 2 | number of times a particular letter shows up in the word 3 | search. 4 | Problem Link: https://edabit.com/challenge/bsPZtsX62zQmRHNjX 5 | */ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | int letterCounter(vector> &arr, char c) { 12 | int count=0; 13 | for(auto v:arr) { 14 | for(char ch:v) { 15 | if(ch==c) 16 | count++; 17 | } 18 | } 19 | return count; 20 | } 21 | 22 | int main(){ 23 | vector > arr(5, vector(6)); 24 | for(auto &v:arr) { 25 | for(char &ch:v) 26 | cin>>ch; 27 | } 28 | char c; 29 | cin>>c; 30 | cout< 5 | 6 | using namespace std; 7 | 8 | int findTheNumber(vector arr){ 9 | // sum will contain the sum of first 10 natural numbers 10 | int sum = 10*(11)/2; 11 | 12 | // arraysum will contain the sum of all the elements in the array 13 | int arraySum = accumulate(arr.begin(),arr.end(),0); 14 | 15 | return sum - arraySum; 16 | } 17 | 18 | int main() { 19 | int a; 20 | vector arr; 21 | for(int i=0;i<9;i++){ 22 | cin>>a; 23 | arr.push_back(a); 24 | } 25 | 26 | int result = findTheNumber(arr); 27 | 28 | cout< 5 | #include 6 | 7 | using namespace std; 8 | 9 | string reverse(string str) { 10 | string ans = ""; 11 | int j = str.size() - 1; 12 | for (int i = 0; i < str.size(); i ++){ 13 | if(isdigit(str[i])){ 14 | ans += str[i]; 15 | }else{ 16 | while(j >= 0 && isdigit(str[j]) && j - 1 >= 0) j --; 17 | if(j >= 0) 18 | ans += str[j]; 19 | j --; 20 | } 21 | } 22 | return ans; 23 | } 24 | 25 | int main() 26 | { 27 | cout< 12 | using namespace std; 13 | 14 | int findodd(vector arr) 15 | { 16 | int i; 17 | map mp; 18 | for(i=0;isecond)%2!=0) 22 | return itr->first; 23 | } 24 | } 25 | 26 | int main() 27 | { 28 | int i,j; 29 | vector arr={1,1,2,2,3,3,4,4,5}; 30 | int odd=findodd(arr); 31 | cout< 6 | using namespace std; 7 | bool isPrime(int x) { 8 | for (int d = 2; d * d <= x; d++) { 9 | if (x % d == 0) 10 | return false; 11 | } 12 | return true; 13 | } 14 | string sumPrime(vector arr) { 15 | string res = ""; 16 | int maxn = *max_element(arr.begin(), arr.end()); 17 | for(int i=2; i<=maxn; i++){ 18 | if(isPrime(i)){ 19 | int localSum = 0; 20 | bool inside = false; 21 | for(auto n: arr) 22 | if(n%i==0) 23 | inside = true, localSum += n; 24 | if(inside) 25 | res += "(" + to_string(i) + " " + to_string(localSum) + ")";} 26 | } 27 | return res; 28 | } 29 | int main(){ 30 | cout << sumPrime({2, 12, 15}); 31 | } -------------------------------------------------------------------------------- /2.Easy/hittingTheJackpot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Problem Task: Create a function that takes in an array (slot machine outcome) 3 | and returns true if all elements in the array are identical, 4 | and false otherwise. The array will contain 4 elements. 5 | Problem Link: https://edabit.com/challenge/5eStPo3wrZRju7j9G 6 | */ 7 | #include 8 | using namespace std; 9 | 10 | bool testJackpot(vector arr, int N){ 11 | 12 | for(int i = 1; i < N; i++){ 13 | if(arr[i] != arr[i-1]) 14 | return false; 15 | } 16 | 17 | return true; 18 | } 19 | 20 | 21 | int main(){ 22 | 23 | const int N = 4; 24 | vector arr; 25 | for(int i = 0; i < N; i++){ 26 | string s; cin >> s; 27 | arr.push_back(s); 28 | } 29 | 30 | testJackpot(arr, N) ? cout << "true" : cout << "false"; 31 | 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /4. Hard/makingABox.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Statement : Create a function that creates a box based on dimension n. 2 | * Problem Link : https://edabit.com/challenge/yHeTBuJ6LDw3nhA7k 3 | */ 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | vector makeBox(int n) { 10 | vector ans; 11 | string temp; 12 | for(int i=0; i>n; 31 | vector result = makeBox(n); 32 | for(int i=0; i 6 | 7 | std::string mysteryFunc(int n){ 8 | int nReversed = 0; 9 | while (n){ 10 | nReversed *=10; 11 | nReversed += n%10; 12 | n/=10; 13 | } 14 | std::ostringstream os; 15 | while (nReversed > 0){ 16 | int digit = nReversed% 10; 17 | nReversed/= 10; 18 | int counter = 1; 19 | while ((nReversed > 0) && (nReversed%10 == digit)){ 20 | nReversed/=10; 21 | ++counter; 22 | } 23 | os< 8 | using namespace std; 9 | void orderedMatrix(int a,int b) 10 | { 11 | int arr[a][b]; 12 | int count=1; 13 | for(int i=0;i>a>>b; 34 | orderedMatrix(a,b); 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /4. Hard/letterDistance.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Given two words, the letter distance is calculated by taking the 3 | absolute value of the difference in character codes and summing up 4 | the difference. 5 | If one word is longer than another, add the difference in lengths 6 | towards the score. 7 | Problem : https://edabit.com/challenge/5Xo5fBrQui9opFWH5 8 | */ 9 | 10 | #include 11 | using namespace std; 12 | 13 | int letterDistance(string str1, string str2) { 14 | int res = 0; 15 | for(int i=0; i> str1 >> str2; 27 | cout << letterDistance(str1, str2) << endl; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /4. Hard/letters.cpp: -------------------------------------------------------------------------------- 1 | // Problem statement: Create a function that returns the number of characters shared between 2 | // two words. 3 | // Probelm Link: https://edabit.com/challenge/qeCS48GXtK9NJLc9C 4 | 5 | #include 6 | using namespace std; 7 | int sharedLetters(string str1,string str2) { 8 | mapa; 9 | mapb; 10 | for (auto i : str1){ 11 | a[i]++; 12 | } 13 | for (auto j : str2){ 14 | b[j]++; 15 | } 16 | string res = ""; 17 | for (auto itr : a){ 18 | if (a[itr.first]>0 && b[itr.first]>0){ 19 | res += itr.first; 20 | a[itr.first] = 0; 21 | b[itr.first] = 0; 22 | } 23 | } 24 | for (auto itr : b){ 25 | if (a[itr.first]>0 && b[itr.first]>0){ 26 | res += itr.first; 27 | a[itr.first] = 0; 28 | b[itr.first] = 0; 29 | } 30 | } 31 | return res.size(); 32 | } 33 | int main(){ 34 | string s1, s2; 35 | cin >> s1; 36 | cin >> s2; 37 | cout << sharedLetters(s1, s2) << endl; 38 | } 39 | -------------------------------------------------------------------------------- /1. Very Easy/animals.cpp: -------------------------------------------------------------------------------- 1 | /* Problem statement : In this challenge, a farmer is asking you to tell him how many legs can be counted among all his animals. The farmer breeds three species: 2 | chickens = 2 legs 3 | cows = 4 legs 4 | pigs = 4 legs 5 | The farmer has counted his animals and he gives you a subtotal for each species. You have to implement a function that returns the total number of legs of all the animals. */ 6 | 7 | // Probelm Link : https://edabit.com/challenge/aADAoRtkbZWEKw9Ap 8 | // Choose one Cateorgy - Very Easy 9 | // question category : algorithms, math 10 | 11 | #include 12 | 13 | using namespace std; 14 | 15 | int animals(int chickens, int cows, int pigs) { 16 | int res; 17 | res = (2*chickens) + (4*cows) + (4*pigs); 18 | return res; 19 | } 20 | 21 | int main() 22 | { 23 | int ch, c, p; 24 | cin>>ch>>c>>p; 25 | 26 | int x = animals(ch, c, p); 27 | 28 | cout< 4 | using namespace std; 5 | 6 | vector> transposeMatrix(vector> arr) { 7 | vector>res(arr[0].size(), vector(arr.size())); 8 | for (int i = 0; i < arr[0].size(); i++) 9 | for (int j = 0; j < arr.size() ; j++) 10 | res[i][j] = arr[j][i]; 11 | return res; 12 | } 13 | int main() 14 | { 15 | int n, m; //size of matrix 16 | cin >> n >> m; 17 | vector>arr(n, vector(m)); 18 | vector>res(m, vector(n)); 19 | for (int i = 0 ; i < n ; i++) 20 | for (int j = 0; j < m ; j++) 21 | cin >> arr[i][j]; 22 | res = transposeMatrix(arr); 23 | for (int i = 0 ; i < m ; i++) 24 | { 25 | for (int j = 0; j < n ; j++) 26 | { 27 | cout << res[i][j] << " "; 28 | } 29 | cout << endl; 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Edabit-Solutions 2 | 3 | ![C++](https://img.shields.io/badge/language-C++-blue?style=for-the-badge) 4 | 5 | ![forks](https://img.shields.io/github/forks/Py-Droid/Edabit-Solutions?style=social) 6 | ![stars](https://img.shields.io/github/stars/Py-Droid/Edabit-Solutions?style=social) 7 | ![license](https://img.shields.io/github/license/Py-Droid/Edabit-Solutions?style=social) 8 | ![contributors](https://img.shields.io/github/contributors/Py-Droid/Edabit-Solutions?style=social) 9 | 10 | Edabit Solutions using Cpp 11 | 12 | ### Author 13 | 14 | 15 | 16 | 17 | 18 | 19 |
aayushi sharma
Aayushi Sharma
Maintainer
20 | 21 | #### Don't forget to Give a Star(⭐) on Repo. 22 | -------------------------------------------------------------------------------- /4. Hard/atbashCipher.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : The Atbash cipher is an encryption method in which each letter of a word is replaced with its "mirror" letter in the alphabet: A <=> Z; B <=> Y; C <=> X; etc. 2 | * Problem Link : https://edabit.com/challenge/977xgdi57bp23ibz5 3 | */ 4 | 5 | #include 6 | 7 | using namespace std; 8 | 9 | string atbash(string str) { 10 | int sz = str.size(); 11 | string ans = ""; 12 | for (int i = 0; i < sz; i ++){ 13 | if('a' <= str[i] && str[i] <= 'z'){ 14 | ans += ((25 - (str[i] - 'a')) + 'a'); 15 | } else if('A' <= str[i] && str[i] <= 'Z'){ 16 | ans += ((25 - (str[i] - 'A')) + 'A'); 17 | } else 18 | ans += str[i]; 19 | } 20 | return ans; 21 | } 22 | 23 | int main() 24 | { 25 | cout << atbash("apple") << '\n'; 26 | cout << atbash("Hello world!") << '\n'; 27 | cout << atbash("Christmas is the 25th of December") << '\n'; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /2.Easy/HowManyVowels.cpp: -------------------------------------------------------------------------------- 1 | /* Problem Statement: Create a function that takes a string and returns the number (count) of vowels contained within it. 2 | * Problem link: https://edabit.com/challenge/jwPaBe2xjE46baPoG */ 3 | 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | bool isVowel(char ch) 10 | { 11 | ch = toupper(ch); 12 | return (ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U'); 13 | } 14 | 15 | int countVowels(std::string str) 16 | { 17 | char ch; 18 | int i, vowels = 0; 19 | for(i = 0; i>str; 33 | int noofvowels = countVowels(str); 34 | cout<>n; 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /5. Very Hard/primeFactorizationOfAnInteger.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : Find all the Prime Factors of an Integer 2 | * Problem Link : https://edabit.com/challenge/8vBvgJMc2uQJpD6d7 3 | */ 4 | 5 | #include 6 | using namespace std; 7 | 8 | vector primeFactorsFunction(int n){ 9 | vector primeFactors; 10 | if(n%2==0){ 11 | primeFactors.push_back(2); 12 | while(n%2==0){ 13 | n/=2; 14 | } 15 | } 16 | for(int i = 3;i<=n;i+=2){ 17 | if(n%i==0){ 18 | primeFactors.push_back(i); 19 | while(n%i==0){ 20 | n /= i; 21 | } 22 | } 23 | } 24 | if( n > 2) { 25 | primeFactors.push_back(n); 26 | } 27 | return primeFactors; 28 | } 29 | 30 | int main() { 31 | int n; 32 | cin>>n; 33 | vector primeFactors = primeFactorsFunction(n); 34 | int noOfPrimes = primeFactors.size(); 35 | for(auto it:primeFactors) { 36 | cout< 4 | using namespace std; 5 | 6 | // function to find the sum of cubes of elements of an array 7 | long sumOfCubes(int a[]) 8 | { 9 | int n=sizeof(a)/sizeof(a[0]); 10 | 11 | // initialize sum 12 | long sum = 0; 13 | 14 | // add cube of the elements to sum 15 | for(int i=0;i<=n;i++){ 16 | sum = sum+(long)(a[i]*a[i]*a[i]); 17 | } 18 | 19 | // required sum 20 | return sum; 21 | } 22 | 23 | // Driver program to test above 24 | int main() 25 | { 26 | int arr[] = {3,4,5}; 27 | cout << "Sum = " 28 | << sumOfCubes(arr); 29 | int b[5] = {}; 30 | cout << "Sum = " 31 | << sumOfCubes(b); 32 | return 0; 33 | } 34 | 35 | 36 | //Output: 37 | 38 | //Sum = 216 Sum = 0 39 | -------------------------------------------------------------------------------- /4. Hard/replaceLettersWithPositionInAlphabet.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Statement : Create a function that takes a string and replaces each letter with its appropriate position in the alphabet. 2 | * Problem Link : https://edabit.com/challenge/rZbXfisPPKbR6yNXn 3 | */ 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | string alphabetIndex(string str) { 9 | string ans; 10 | for(int i=0; i='a' && str[i]<='z') { 12 | ans+=to_string(str[i]-'a'+1); 13 | ans +=' '; 14 | } 15 | //Note - Both Uppercase and Lowercase alphabets is kept at same index 16 | else if(str[i]>='A' && str[i]<='Z') { 17 | ans += to_string(str[i]-'A'+1); 18 | ans +=' '; 19 | } 20 | // Note - Ignore all other charaters except alphabets. 21 | } 22 | ans.pop_back(); 23 | return ans; 24 | } 25 | 26 | int main() { 27 | string s; 28 | getline(cin, s); // Input string containing spaces. 29 | string result = alphabetIndex(s); 30 | cout< 7 | using namespace std; 8 | 9 | bool timeForMilkAndCookies(int year, int month, int day) { 10 | if(month==11 && day==24){ 11 | return true; 12 | } 13 | else { 14 | return false; 15 | } 16 | } 17 | 18 | int main() 19 | { 20 | bool res; 21 | int y,m,d; 22 | cin>>y>>m>>d; 23 | 24 | res = timeForMilkAndCookies(y,m,d); 25 | if(res){ 26 | cout<<"True"; 27 | } else { 28 | cout<<"False"; 29 | } 30 | 31 | return 0; 32 | } -------------------------------------------------------------------------------- /6. Expert/phoneLetterCombinationAlternative.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | void dfs(string digits, unordered_map myMap, int idx, vector path, vector& res) { 5 | if (!path.empty() && path.size() == digits.size()) { 6 | string s = ""; 7 | for (auto& c: path) 8 | s += c; 9 | res.push_back(s); 10 | return; 11 | } 12 | for (auto& c: myMap[digits[idx]]) { 13 | path.push_back(c); 14 | dfs(digits, myMap, idx+1, path, res); 15 | path.pop_back(); 16 | } 17 | } 18 | void letterCombinations(string digits) { 19 | unordered_map myMap = {{'2',"abc"}, {'3',"def"}, {'4',"ghi"}, 20 | {'5',"jkl"}, {'6',"mno"}, {'7',"pqrs"}, {'8',"tuv"}, {'9',"wxyz"}}; 21 | vector res; 22 | dfs(digits, myMap, 0, {}, res); 23 | for(auto a:res) 24 | cout< 7 | using namespace std; 8 | 9 | bool isPalindrome(string s) { 10 | string ans=""; 11 | for(int i=0; i= s.size() || numRows <= 1){ 22 | return s; 23 | } 24 | for(int i = 0; i < numRows; ++i){ 25 | int con = i; 26 | while(con < n){ 27 | apt.push_back(s[con]); 28 | if(i > 0 && i < numRows-1){ 29 | int tie2 = (numRows - i - 1)*2; 30 | if(con+tie2 < n) 31 | apt.push_back(s[con+tie2]); 32 | } 33 | con += tie1; 34 | } 35 | } 36 | return apt; 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /4. Hard/sortByLength.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | // Function to print the sorted array of string 5 | void printArraystring(string,int); 6 | 7 | // Function to Sort the array of string 8 | // according to lengths. This function 9 | // implements Insertion Sort. 10 | void sort(string s[], int n) 11 | { 12 | for (int i=1 ;i= 0 && temp.length() < s[j].length()) 19 | { 20 | s[j+1] = s[j]; 21 | j--; 22 | } 23 | s[j+1] = temp; 24 | } 25 | } 26 | 27 | // Function to print the sorted array of string 28 | void printArraystring(string str[], int n) 29 | { 30 | for (int i=0; i 5 | #include 6 | using namespace std; 7 | 8 | vector minMax(vector arr) 9 | { 10 | float mini = arr[0]; 11 | float maxi = arr[0]; 12 | vector result; 13 | for (int i = 0; i < arr.size(); i++) 14 | { 15 | mini = min(mini, arr[i]); 16 | maxi = max(maxi, arr[i]); 17 | } 18 | result.push_back(mini); 19 | result.push_back(maxi); 20 | return result; 21 | } 22 | 23 | int main() 24 | { 25 | 26 | int numberOfEle; 27 | cin >> numberOfEle; 28 | 29 | vector arr; 30 | float ele; 31 | 32 | for (int i = 0; i < numberOfEle; i++) 33 | { 34 | cin >> ele; 35 | arr.push_back(ele); 36 | } 37 | 38 | vector result; 39 | 40 | result = minMax(arr); 41 | cout << result[0] << " " << result[1]; 42 | return 0; 43 | } 44 | knln 45 | vhjbvmnklsdknasd 46 | sdsad 47 | sdasd -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Aayushi Sharma 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/new-issue-for-adding-probem.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: New issue for adding probem 3 | about: follow all guidelines before making PR 4 | title: '' 5 | labels: C++, hacktoberfest 6 | assignees: '' 7 | 8 | --- 9 | 10 | Before jumping into Pr first comment for assign. 11 | 12 | **Problem statement** : 13 | **Probelm Link** : 14 | **Choose one Cateorgy** - Very Easy, Easy, Medium, Hard, Very Hard, Expert 15 | **question category** : 16 | 17 | --- 18 | Before submitting a PR please Check some details. 19 | 20 | - [ ] fileName formet should be in camelcase 21 | example- returnTheNextNumber.py 22 | - [ ] Choose label for Problem , example- "good first issue", "easy" 23 | - [ ] In file there should be problem statement and link to problem 24 | ```cpp 25 | /* Problem-Task : This program will add two numbers 26 | * Problem Link : https://edabit.com/challenge/SFzHtm63XT6EYNHWY 27 | */ 28 | int main() { 29 | int bla; 30 | return 0; 31 | } 32 | ``` 33 | 34 | This repository is vaild for HacktoberFest2020 35 | 36 | Read before making PR - [How to contribute on Github](https://www.dataschool.io/how-to-contribute-on-github/) 37 | Good Luck, 38 | -------------------------------------------------------------------------------- /4. Hard/sharedLetters.cpp: -------------------------------------------------------------------------------- 1 | // Problem statement: Create a function that returns the number of characters shared between two words. 2 | // Probelm Link: https://edabit.com/challenge/qeCS48GXtK9NJLc9C 3 | 4 | /* 5 | Sample test case 6 | 7 | 3 8 | apple 9 | meaty 10 | class 11 | last 12 | spout 13 | shout 14 | */ 15 | #include 16 | using namespace std; 17 | 18 | int sharedLetters(string str1, string str2) { 19 | string str3, str4; 20 | int x=0; 21 | for(int i=0;i>n; 51 | for(int i=0;i>s1; 53 | cin>>s2; 54 | cout< 6 | using namespace std; 7 | 8 | int sumDigProd(int a=0, int b=0, int c=0, int d=0, int e=0, int f=0, int g=0, int h=0, int i=0, int j=0, int k=0, int l=0, int m=0, int n=0, int o=0, int p=0, int q=0, int r=0, int s=0, int t=0, int u=0, int v=0, int w=0, int x=0, int y=0, int z=0) //function allows upto 26 numbers 9 | { 10 | int answer=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z; 11 | while(answer/10!=0) 12 | { 13 | int product=answer; 14 | int currProduct=1; 15 | while(product!=0) 16 | { 17 | currProduct*=product%10; 18 | product/=10; 19 | } 20 | answer=currProduct; 21 | } 22 | return answer; 23 | } 24 | int main() 25 | { 26 | cout<<"sumDigProd(16,28) = "< list = plc(num, n, table); 26 | for (auto word : list){ 27 | cout << word << " "; 28 | } 29 | } 30 | int main(){ 31 | int num[] = { 2, 3, 4 }; 32 | int n = sizeof(num) / sizeof(num[0]); 33 | letterCombinations(num, n); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /6. Expert/rollTheDice.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task: Function that computes how many possible combinations of n 6-sided die will produce a certain number 2 | * Problem Link: https://edabit.com/challenge/6ejJ6e7fLdqzGPa3q 3 | */ 4 | 5 | #include 6 | using namespace std; 7 | 8 | int diceRoll(int numDice, int outcome) { 9 | int combinations = 0; 10 | int dice[numDice]; 11 | for(int i = 0; i < numDice; i++) dice[i] = 1; 12 | bool done = false; 13 | while(!done) { 14 | int sum = 0; 15 | for(int i = 0; i < numDice; i++) sum += dice[i]; 16 | if(sum == outcome){ 17 | combinations++; 18 | } 19 | done = true; 20 | for(int i = 0; i < numDice; i++) { 21 | if(dice[i] != 6){ 22 | done = false; 23 | } 24 | } 25 | dice[0]++; 26 | for(int i = 0; i < numDice - 1; i++) { 27 | if(dice[i] > 6){ 28 | dice[i] = 1; 29 | dice[i + 1]++; 30 | } 31 | else { 32 | break; 33 | } 34 | } 35 | } 36 | return combinations; 37 | } 38 | 39 | int main() { 40 | std::string numDice; 41 | std::string outcome; 42 | std::cout << "Enter number of dice: "; 43 | std::getline(std::cin, numDice); 44 | std::cout << "Enter outcome: "; 45 | std::getline(std::cin, outcome); 46 | std::cout << "There are " << diceRoll(std::stoi(numDice), std::stoi(outcome)) << " possible combinations." << std::endl; 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /5. Very Hard/hexToBinaryUsingLoops.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : This will take a HEX number and returns the binary equivalent (as a string). 2 | * Problem Link : https://edabit.com/challenge/NX5uRSLwuXwsqKfiR 3 | */ 4 | 5 | #include 6 | using namespace std; 7 | 8 | string toBinary(string hexadecimal) 9 | { 10 | int position=2; //since the first two positions will be occupied by 0x 11 | int curr; //stores current hexadecimal digit in decimal 12 | char binary[8]; 13 | for(int i=0;i<8;i++) 14 | binary[i]='0'; //initialises binary to "00000000" 15 | while(hexadecimal[position]!='\0') 16 | { 17 | if(hexadecimal[position]>=65) 18 | curr=hexadecimal[position]-'A'+10; 19 | else 20 | curr=hexadecimal[position]-'0'; 21 | 22 | int binaryPos=(4*(position-2))+3; 23 | 24 | while(curr>0) //converts curr to binary and stores in the required position of binary 25 | { 26 | binary[binaryPos]=(char)'0'+curr%2; 27 | curr/=2; 28 | binaryPos--; 29 | } 30 | position++; 31 | } 32 | return binary; 33 | } 34 | int main() 35 | { 36 | string hexadecimal; 37 | cout<<"Enter a hexadecimal number (in 0x__ notation): "; 38 | cin>>hexadecimal; 39 | cout<<"The number in binary is: "< 2 | using namespace std; 3 | int main() 4 | { 5 | int matrix[10][10], transMatrix[10][10], row, col; 6 | //Getting the rows from user and storing in row 7 | cout << "Enter the number of rows: "; 8 | cin >> row; 9 | //Getting the columns from user and storing in col 10 | cout << "Enter the number of columns: "; 11 | cin >> col; 12 | 13 | /* Asking the user to input the elements of matrix 14 | * and storing them in the matrix array 15 | */ 16 | cout << "Enter elements of matrix: " << endl; 17 | for (int i = 0; i < row; i++) 18 | { 19 | for (int j = 0; j < col; j++) 20 | { 21 | cin >> matrix[i][j]; 22 | } 23 | } 24 | // Finding the transpose matrix. 25 | for (int i = 0; i < row; i++) 26 | { 27 | for (int j = 0; j < col; j++) 28 | { 29 | transMatrix[j][i] = matrix[i][j]; 30 | } 31 | } 32 | //Displaying the transpose matrix 33 | cout << "Transpose of Matrix: " << endl; 34 | for (int i = 0; i < col; i++) 35 | { 36 | for (int j = 0; j < row; j++) 37 | { 38 | cout << transMatrix[i][j] << " "; 39 | /* This is just to format the output 40 | * so you can see the matrix format 41 | * in the output transpose matrix. 42 | */ 43 | if (j == row - 1) 44 | cout << endl; 45 | } 46 | } 47 | return 0; 48 | } -------------------------------------------------------------------------------- /4. Hard/daysBetweendates.cpp: -------------------------------------------------------------------------------- 1 | //Problem statement :Create a function that takes two 2 | //dates and returns the number of days between the first 3 | //and second date. 4 | //Probelm Link: https://edabit.com/challenge/3hdXjfJozQySRC3gE 5 | 6 | #include 7 | using namespace std; 8 | void days(int,int,int,int,int,int); 9 | int month(int,int); 10 | int mon[12]={31,28,31,30,31,30,31,31,30,31,30,31}; 11 | 12 | int main(){ 13 | int a1,b1,c1,a2,b2,c2; 14 | cout<<"Enter first date(dd mm yyyy) : "; 15 | cin>>a1>>b1>>c1; 16 | cout<<"\nEnter second date(dd mm yyyy) : "; 17 | cin>>a2>>b2>>c2; 18 | if(c2>=c1) 19 | days(c1,c2,b1,b2,a1,a2); 20 | else 21 | days(c2,c1,b2,b1,a2,a1); 22 | return 0; 23 | } 24 | 25 | void days(int y1,int y2,int m1,int m2,int d1,int d2){ 26 | int count=0,i; 27 | for(i=y1;i 6 | using namespace std; 7 | 8 | // Function that returns true if n 9 | // is prime else returns false 10 | bool isPrime(int n) 11 | { 12 | // Corner cases 13 | if (n <= 1) return false; 14 | if (n <= 3) return true; 15 | 16 | // This is checked so that we can skip 17 | // middle five numbers in below loop 18 | if (n%2 == 0 || n%3 == 0) return false; 19 | 20 | for (int i=5; i*i<=n; i=i+6) 21 | if (n%i == 0 || n%(i+2) == 0) 22 | return false; 23 | 24 | return true; 25 | } 26 | 27 | // Function to return the smallest 28 | // prime number greater than N 29 | int nextPrime(int N) 30 | { 31 | 32 | // Base case 33 | if (N <= 1) 34 | return 2; 35 | 36 | int prime = N; 37 | bool found = false; 38 | 39 | // Loop continuously until isPrime returns 40 | // true for a number greater than n 41 | while (!found) { 42 | prime++; 43 | 44 | if (isPrime(prime)) 45 | found = true; 46 | } 47 | 48 | return prime; 49 | } 50 | 51 | // Driver code 52 | int main() 53 | { 54 | int N; 55 | cout<<"Enter the no. - "; 56 | cin>>N; 57 | 58 | cout << nextPrime(N); 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /4. Hard/filterPrime.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | const int sz = 1e5; 5 | bool isPrime[sz + 1]; 6 | 7 | // Function for Sieve of Eratosthenes 8 | void sieve() 9 | { 10 | memset(isPrime, true, sizeof(isPrime)); 11 | 12 | isPrime[0] = isPrime[1] = false; 13 | 14 | for (int i = 2; i * i <= sz; i++) { 15 | if (isPrime[i]) { 16 | for (int j = i * i; j < sz; j += i) { 17 | isPrime[j] = false; 18 | } 19 | } 20 | } 21 | } 22 | 23 | // Function to print the elements of the array 24 | void printArray(int arr[], int len) 25 | { 26 | for (int i = 0; i < len; i++) { 27 | cout << arr[i] << ' '; 28 | } 29 | } 30 | 31 | // Function to remove all the prime numbers 32 | void removePrimes(int arr[], int len) 33 | { 34 | // Generate primes 35 | sieve(); 36 | 37 | // Traverse the array 38 | for (int i = 0; i < len; i++) { 39 | 40 | // If the current element is prime 41 | if (isPrime[arr[i]]) { 42 | 43 | // Shift all the elements on the 44 | // right of it to the left 45 | for (int j = i; j < len; j++) { 46 | arr[j] = arr[j + 1]; 47 | } 48 | 49 | // Decrease the loop counter by 1 50 | // to check the shifted element 51 | i--; 52 | 53 | // Decrease the length 54 | len--; 55 | } 56 | } 57 | 58 | // Print the updated array 59 | printArray(arr, len); 60 | } 61 | 62 | 63 | int main() 64 | { 65 | int arr[] = {1,2,3,4,5,6,7,8,9}; 66 | int len = sizeof(arr) / sizeof(int); 67 | 68 | removePrimes(arr, len); 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /3. Medium/Arrays/RainwaterTrapping.cpp: -------------------------------------------------------------------------------- 1 | //Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. 2 | 3 | #include 4 | using namespace std; 5 | // Function to return the maximum 6 | // water that can be stored 7 | int maxWater(int height[], int n) 8 | { 9 | // Stores the indices of the bars 10 | stack st; 11 | // Stores the final result 12 | int ans = 0; 13 | // Loop through the each bar 14 | for(int i = 0; i < n; i++) 15 | { 16 | while ((!st.empty()) && 17 | (height[st.top()] < height[i])) 18 | { 19 | // Store the height of the top 20 | // and pop it. 21 | int pop_height = height[st.top()]; 22 | st.pop(); 23 | if (st.empty()) 24 | break; 25 | // Get the distance between the 26 | // left and right boundary of 27 | // popped bar 28 | int distance = i - st.top() - 1; 29 | 30 | // Calculate the min. height 31 | int min_height = min(height[st.top()], 32 | height[i]) - 33 | pop_height; 34 | 35 | ans += distance * min_height; 36 | } 37 | // If the stack is either empty or 38 | // height of the current bar is less than 39 | // or equal to the top bar of stack 40 | st.push(i); 41 | } 42 | return ans; 43 | } 44 | 45 | int main() 46 | { 47 | //let us take a sample array for purpose 48 | int arr[] = { 0, 1, 0, 2, 1, 0, 49 | 1, 3, 2, 1, 2, 1 }; 50 | int n = sizeof(arr) / sizeof(arr[0]); 51 | 52 | cout << maxWater(arr, n); 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /4. Hard/containDuplicates.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | using namespace std; 7 | bool areChractersUnique(string str) 8 | { 9 | // An integer to store presence/absence 10 | // of 26 characters using its 32 bits. 11 | int checker = 0; 12 | 13 | for (int i = 0; i < str.length(); ++i) 14 | { 15 | int val = (str[i]-'a'); 16 | 17 | // If bit corresponding to current 18 | // character is already set 19 | if ((checker & (1 << val)) > 0) 20 | return false; 21 | 22 | // set bit in checker 23 | checker |= (1 << val); 24 | } 25 | 26 | return true; 27 | } 28 | 29 | void DuplicateLetters(string str){ 30 | // Initialise the istringstream 31 | // with the given string 32 | istringstream iss(str); 33 | int flag=0; 34 | 35 | // Iterate the istringstream 36 | // using do-while loop 37 | do { 38 | string subs; 39 | 40 | // Get the word from the istringstream 41 | iss >> subs; 42 | 43 | // make flag=1 if a word with duplicate found and print false 44 | if (subs.length()>1 && areChractersUnique(subs)==0){ 45 | cout<<"False"; 46 | flag=1; 47 | break; 48 | } 49 | 50 | 51 | } while (iss); 52 | //if no word with duplicate print true 53 | if(flag==0){ 54 | cout<<"True"; 55 | } 56 | 57 | } 58 | 59 | int main() 60 | { 61 | DuplicateLetters("this iis the word"); 62 | return 0; 63 | } -------------------------------------------------------------------------------- /5. Very Hard/persistence.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : The additive persistence of an integer, n, is the number of times you have to replace n with the sum of its digits until n becomes a single digit integer. 2 | 3 | The multiplicative persistence of an integer, n, is the number of times you have to replace n with the product of its digits until n becomes a single digit integer. 4 | 5 | Create two functions that take an integer as an argument and: 6 | 7 | Return its additive persistence. 8 | Return its multiplicative persistence. 9 | 10 | * Problem Link : https://edabit.com/challenge/vHvu4Wis8RhmQbwXm 11 | */ 12 | 13 | #include 14 | using namespace std; 15 | 16 | int additivePersistence(int n) 17 | { 18 | int counter=0; 19 | while(n/10>0) 20 | { 21 | counter++; 22 | int temp=0; 23 | while(n!=0) 24 | { 25 | temp+=n%10; 26 | n/=10; 27 | } 28 | n=temp; 29 | } 30 | return counter; 31 | } 32 | 33 | int multiplicativePersistence(int n) 34 | { 35 | int counter=0; 36 | while(n/10>0) 37 | { 38 | counter++; 39 | int temp=1; 40 | while(n!=0) 41 | { 42 | temp*=n%10; 43 | n/=10; 44 | } 45 | n=temp; 46 | } 47 | return counter; 48 | } 49 | 50 | int main() 51 | { 52 | int n; 53 | cout<<"Enter n: "; 54 | cin>>n; 55 | cout<<"Additive Persistence of n: "< 4 | using namespace std; 5 | std::vector switchNotation(std::vector scores, std::string desired_notation) { 6 | if (desired_notation == "normal") 7 | { 8 | std :: vector res; 9 | for (auto i : scores) 10 | { 11 | std ::string l = std ::to_string(i); 12 | int z = 0; 13 | for (auto j : l) 14 | { 15 | z += j - '0'; 16 | } 17 | res.push_back(z); 18 | } 19 | return res; 20 | } 21 | else 22 | { 23 | std :: vector res; 24 | for (auto i : scores) 25 | { 26 | int l = i % 5; 27 | std ::string f(i / 5, '5'); 28 | if (l != 0) 29 | f += std ::to_string(l); 30 | res.push_back(stoi(f)); 31 | } 32 | return res; 33 | } 34 | } 35 | int main() 36 | { 37 | int t;//number of testcases; 38 | cin >> t; 39 | while (t--) 40 | { 41 | std :: vector scores, res; 42 | int n;//size of array; 43 | cin >> n; 44 | while (n--) 45 | { 46 | int x; 47 | cin >> x; 48 | scores.push_back(x); 49 | } 50 | std :: string desired_notation;//notation type 51 | cin >> desired_notation; 52 | res = switchNotation(scores, desired_notation); 53 | for ( auto i : res ) 54 | { 55 | cout << i << " "; 56 | } 57 | cout << endl; 58 | 59 | } 60 | } -------------------------------------------------------------------------------- /4. Hard/slidingSum.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : Create a function that returns the subarrays of n consecutive elements from the original element that sum up to k. 2 | * Problem Link : https://edabit.com/challenge/SkJoSKw9i3GQf62k5 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | vector> slidingSum(vector arr, int n, int k) { 11 | vector > ans; 12 | int count = 0, sum = 0, i = 0, j = 0; 13 | while(i < arr.size() || j < arr.size()){ 14 | while(j - i < n && j < arr.size()){ 15 | sum += arr[j]; 16 | j ++; 17 | } 18 | if(sum == k && j - i == n){ 19 | vector buf; 20 | for (int b = i; b < j; b ++) 21 | buf.push_back(arr[b]); 22 | ans.push_back(buf); 23 | } 24 | sum -= arr[i]; 25 | i ++; 26 | } 27 | return ans; 28 | } 29 | 30 | void tester(vector arr, int n, int k, int testNumber){ 31 | cout << "Test number: #" << testNumber << '\n'; 32 | vector > ans = slidingSum(arr, n, k); 33 | for (int i = 0; i < ans.size(); i ++){ 34 | for (int j = 0; j < ans[i].size(); j ++) 35 | cout << ans[i][j] << ' '; 36 | cout << '\n'; 37 | } 38 | } 39 | int main() 40 | { 41 | vector test1{3, 4, 1, 9, 9, 0, 3, 5, 4}; 42 | vector test2{1, 4, 2, 3, 5, 0}; 43 | vector test3{5, 5, 5, 5, 5}; 44 | vector test4{5, 5, 5, 5, 5}; 45 | tester(test1, 3, 8, 1); 46 | tester(test2, 2, 5, 2); 47 | tester(test3, 1, 5, 3); 48 | tester(test4, 5, 24, 4); 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /5. Very Hard/caesarsCipher.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /* Problem-Task : 6 | Julius Caesar protected his confidential information by encrypting it using a cipher. Caesar's cipher (check Resources tab for more info) shifts each letter by a number of letters. 7 | If the shift takes you past the end of the alphabet, just rotate back to the front of the alphabet. In the case of a rotation by 3, w, x, y and z would map to z, a, b and c. 8 | 9 | Create a function that takes a string s (text to be encrypted) and an integer k (the rotation factor). It should return an encrypted string. 10 | 11 | Sample Tests: 12 | caesarCipher("middle-Outz", 2) ➞ "okffng-Qwvb" 13 | 14 | // m -> o 15 | // i -> k 16 | // d -> f 17 | // d -> f 18 | // l -> n 19 | // e -> g 20 | // - - 21 | // O -> Q 22 | // u -> w 23 | // t -> v 24 | // z -> b 25 | 26 | caesarCipher("Always-Look-on-the-Bright-Side-of-Life", 5) 27 | ➞ "Fqbfdx-Qttp-ts-ymj-Gwnlmy-Xnij-tk-Qnkj" 28 | 29 | caesarCipher("A friend in need is a friend indeed", 20) 30 | ➞ "U zlcyhx ch hyyx cm u zlcyhx chxyyx" 31 | 32 | * Problem Link : https://edabit.com/challenge/GmPfqu2jmLDBD2NYS 33 | */ 34 | 35 | string caesarCipher(std::string s, int k) 36 | { 37 | int n = s.size(); 38 | string ans = ""; 39 | 40 | for (auto c : s) 41 | { 42 | if (c >= 'a' && c <= 'z') 43 | { 44 | int t = c - 'a'; 45 | t = (t + k) % 26; 46 | ans += (char)(t + 'a'); 47 | } 48 | else if (c >= 'A' && c <= 'Z') 49 | { 50 | int t = c - 'A'; 51 | t = (t + k) % 26; 52 | ans += (char)(t + 'A'); 53 | } 54 | else 55 | ans += c; 56 | } 57 | return ans; 58 | } 59 | 60 | int main() 61 | { 62 | //input 63 | string s; 64 | int k; 65 | getline(cin, s); 66 | cin >> k; 67 | 68 | cout << caesarCipher(s, k) << endl; 69 | return 0; 70 | } -------------------------------------------------------------------------------- /5. Very Hard/hexToBinary.cpp: -------------------------------------------------------------------------------- 1 | /* Problem-Task : This will take a HEX number and returns the binary equivalent (as a string). 2 | * Problem Link : https://edabit.com/challenge/NX5uRSLwuXwsqKfiR 3 | */ 4 | 5 | #include 6 | using namespace std; 7 | void toBinary(string hexnum) 8 | { 9 | long int i = 0; 10 | 11 | while (hexnum[i]) { 12 | 13 | switch (hexnum[i]) { 14 | case '0': 15 | cout << "0000"; 16 | break; 17 | case 'x': 18 | cout << ""; 19 | break; 20 | case '1': 21 | cout << "0001"; 22 | break; 23 | case '2': 24 | cout << "0010"; 25 | break; 26 | case '3': 27 | cout << "0011"; 28 | break; 29 | case '4': 30 | cout << "0100"; 31 | break; 32 | case '5': 33 | cout << "0101"; 34 | break; 35 | case '6': 36 | cout << "0110"; 37 | break; 38 | case '7': 39 | cout << "0111"; 40 | break; 41 | case '8': 42 | cout << "1000"; 43 | break; 44 | case '9': 45 | cout << "1001"; 46 | break; 47 | case 'A': 48 | case 'a': 49 | cout << "1010"; 50 | break; 51 | case 'B': 52 | case 'b': 53 | cout << "1011"; 54 | break; 55 | case 'C': 56 | case 'c': 57 | cout << "1100"; 58 | break; 59 | case 'D': 60 | case 'd': 61 | cout << "1101"; 62 | break; 63 | case 'E': 64 | case 'e': 65 | cout << "1110"; 66 | break; 67 | case 'F': 68 | case 'f': 69 | cout << "1111"; 70 | break; 71 | 72 | default: 73 | cout << "\n Invalid hexadecimal digit " 74 | << hexnum[i]; 75 | } 76 | i++; 77 | } 78 | } 79 | 80 | int main() 81 | { 82 | char hexnum[100]; 83 | cout<<"Enter a Hexadecimal number for converting it to Binary :"; 84 | cin>>hexnum; 85 | cout << "\nEquivalent Binary value is : "; 86 | toBinary(hexnum); 87 | 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /5. Very Hard/SupperEggDrop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | /* Problem task : You are given K eggs, and you have access to a building with N floors from 1 to N. Each egg is identical in function, and if an egg breaks, you cannot drop it again. 3 | You know that there exists a floor F with 0 <= F <= N such that any egg dropped at a floor higher than F will break, and any egg dropped at or below floor F will not break. 4 | Each move, you may take an egg (if you have an unbroken one) and drop it from any floor X (with 1 <= X <= N). 5 | Your goal is to know with certainty what the value of F is. 6 | What is the minimum number of moves that you need to know with certainty what F is, regardless of the initial value of F? 7 | 8 | Problem link : https://leetcode.com/problems/super-egg-drop/ 9 | 10 | */ 11 | 12 | 13 | using namespace std; 14 | 15 | int superEggDrop(int K, int N) { 16 | /*Create a 2D dp matrix where jth cell of ith row represents the minimum number of trials needed to check i floors using j eggs. */ 17 | 18 | int eggs = K, floors = N; 19 | 20 | vector> dp(floors+1,vector(eggs+1,0)); 21 | 22 | // case 1: when there are 0 floors 23 | for(int egg = 0; egg<=eggs; egg++) dp[0][egg] = 0; 24 | // case 2: when there are 1 floors 25 | for(int egg = 0; egg<=eggs; egg++) dp[1][egg] = 1; 26 | // case 3: when there are 0 eggs 27 | for(int floor=0; floor<=floors; floor++) dp[floor][0] = 0; 28 | // case 4: when there are 1 eggs 29 | for(int floor=0; floor<=floors; floor++) dp[floor][1] = floor; 30 | 31 | for(int egg=2; egg<=eggs; egg++) { 32 | for(int floor=2; floor<=floors; floor++) { 33 | int mn = INT_MAX; 34 | // choosing an ith floor between 1 to floor 35 | for(int i=1; i<=floor; i++) { 36 | // dp[i - 1][egg-1] means to find the answer when 37 | // the egg is broken at ith floor 38 | // dp[floor - i][egg] means to find the answer 39 | // when the egg is not broken at ith floor 40 | int ans = 1 + max(dp[i-1][egg-1],dp[floor-i][egg]); 41 | mn = min(ans,mn); 42 | } 43 | dp[floor][egg] = mn; 44 | } 45 | } 46 | 47 | return dp[floors][eggs]; 48 | } 49 | 50 | int main(){ 51 | int n,k; 52 | cin>>n>>k; 53 | cout< 6 | #include 7 | struct States{ 8 | int x,y,z; 9 | int &operator[]( int i){ 10 | if(i == 0) 11 | return x; 12 | else if(i == 1) 13 | return y; 14 | else if(i==2) 15 | return z; 16 | return z;} 17 | }; 18 | bool operator==(States& a,States& b){ 19 | return a.x == b.x && a.y == b.y && a.z==b.z; 20 | } 21 | bool IsHere(std::list states,States element) 22 | { 23 | for(auto state:states) 24 | if((state==element)) 25 | return true; 26 | return false; 27 | } 28 | 29 | int waterjug(States Capacities, States Goal){ 30 | std::list>> Queue; 31 | std::list deadends; 32 | Queue.push_back(std::make_pair(States{0,0,Capacities.z},std::list{{}})); 33 | Queue.front().second.pop_front(); 34 | while(Queue.size()>0){ 35 | auto currentItem = Queue.front(); 36 | Queue.pop_front(); 37 | auto state = currentItem.first; 38 | 39 | if (!(state==Goal)){ 40 | for (int i = 0; i < 3; i++) 41 | { 42 | if(state[i] != 0) 43 | { 44 | for (int j = 1; j < 3; j++) 45 | { 46 | int index = (i+j)%3; 47 | int val = state[index]; 48 | if(val < Capacities[index]) 49 | { 50 | States NewState(state); 51 | int remain = Capacities[index] - val; 52 | if(state[i] > remain){ 53 | NewState[i] = state[i] - remain; 54 | NewState[index] = Capacities[index]; 55 | } 56 | else{ 57 | NewState[index] += state[i]; 58 | NewState[i] = 0; 59 | } 60 | 61 | if(!IsHere(currentItem.second,NewState)) 62 | { 63 | if(!IsHere(deadends,NewState)) 64 | { 65 | currentItem.second.push_back(NewState); 66 | Queue.push_back(make_pair(NewState,currentItem.second)); 67 | } 68 | }else { 69 | deadends.push_back(NewState); 70 | } 71 | } 72 | } 73 | 74 | } 75 | } 76 | } 77 | else 78 | { 79 | return currentItem.second.size(); 80 | } 81 | } 82 | return 0; 83 | } -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Transcriptase 2 | We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's: 3 | 4 | - Reporting a bug 5 | - Discussing the current state of the code 6 | - Submitting a fix 7 | - Proposing new features 8 | - Becoming a maintainer 9 | 10 | ## We Develop with Github 11 | We use github to host code, to track issues and feature requests, as well as accept pull requests. 12 | 13 | ## We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests 14 | Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests: 15 | 16 | 1. Fork the repo and create your branch from `master`. 17 | 2. If you've added code that should be tested, add tests. 18 | 3. If you've changed APIs, update the documentation. 19 | 4. Ensure the test suite passes. 20 | 5. Make sure your code lints. 21 | 6. Issue that pull request! 22 | 23 | ## Any contributions you make will be under the MIT Software License 24 | In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern. 25 | 26 | ## Report bugs using Github's [issues](https://github.com/briandk/transcriptase-atom/issues) 27 | We use GitHub issues to track public bugs. Report a bug by [opening a new issue](); it's that easy! 28 | 29 | ## Write bug reports with detail, background, and sample code 30 | [This is an example](http://stackoverflow.com/q/12488905/180626) of a bug report I wrote, and I think it's not a bad model. Here's [another example from Craig Hockenberry](http://www.openradar.me/11905408), an app developer whom I greatly respect. 31 | 32 | **Great Bug Reports** tend to have: 33 | 34 | - A quick summary and/or background 35 | - Steps to reproduce 36 | - Be specific! 37 | - Give sample code if you can. [My stackoverflow question](http://stackoverflow.com/q/12488905/180626) includes sample code that *anyone* with a base R setup can run to reproduce what I was seeing 38 | - What you expected would happen 39 | - What actually happens 40 | - Notes (possibly including why you think this might be happening, or stuff you tried that didn't work) 41 | 42 | People *love* thorough bug reports. I'm not even kidding. 43 | 44 | ## Use a Consistent Coding Style 45 | I'm again borrowing these from [Facebook's Guidelines](https://github.com/facebook/draft-js/blob/a9316a723f9e918afde44dea68b5f9f39b7d9b00/CONTRIBUTING.md) 46 | 47 | * 2 spaces for indentation rather than tabs 48 | * You can try running `npm run lint` for style unification 49 | 50 | ## License 51 | By contributing, you agree that your contributions will be licensed under its MIT License. 52 | 53 | ## References 54 | This document was adapted from the open-source contribution guidelines for [Facebook's Draft](https://github.com/facebook/draft-js/blob/a9316a723f9e918afde44dea68b5f9f39b7d9b00/CONTRIBUTING.md) 55 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at ayushi98965@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | --------------------------------------------------------------------------------