Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

A 45-day coding challenge organized by Amity Coding Club, featuring daily coding problems and solutions in C++, Python, JavaScript, and Golang.

License

Notifications You must be signed in to change notification settings

AshishBytes/ACC45DAYSOFCODE-2023

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


ACC45DAYSOFCODE-2023

This is my 45 days of code challenge repository organize by Amity Coding Club that is official club of Amity University Gwalior

Progress table

Contributing:

Please take a quick look at the contribution guidelines first. Thanks to all contributors; you rock!


Days and Level Cpp Python JavaScript Golang
Day - 01 - Beginner βœ… βœ… βœ… βœ…
Day - 02 - Beginner βœ… βœ… βœ… βœ…
Day - 03 - Beginner βœ… βœ… βœ… βœ…
Day - 04 - Beginner βœ… βœ… βœ… βœ…
Day - 04 - Intermediate βœ… βœ… ❌ ❌
Day - 05 - Beginner βœ… βœ… βœ… βœ…
Day - 05 - Intermediate βœ… βœ… ❌ βœ…
Day - 06 - Beginner βœ… βœ… βœ… βœ…
Day - 06 - Intermediate ❌ ❌ ❌ ❌
Day - 07 - Beginner βœ… ❌ ❌ ❌
Day - 07 - Intermediate ❌ ❌ ❌ ❌
Day - 08 - Beginner βœ… βœ… ❌ βœ…
Day - 08 - Intermediate βœ… βœ… ❌ ❌
Day - 09 - Beginner ❌ ❌ ❌ ❌
Day - 09 - Intermediate βœ… ❌ ❌ βœ…
Day - 10 - Beginner βœ… βœ… ❌ βœ…
Day - 10 - Intermediate βœ… βœ… ❌ βœ…
Day - 11 - Beginner ❌ ❌ ❌ ❌
Day - 11 - Intermediate βœ… βœ… ❌ ❌
Day - 12 - Beginner βœ… βœ… βœ… βœ…
Day - 12 - Intermediate βœ… βœ… ❌ βœ…
Day - 13 - Beginner βœ… βœ… ❌ βœ…
Day - 13 - Intermediate ❌ ❌ ❌ ❌
Day - 14 - Beginner ❌ ❌ ❌ ❌
Day - 14 - Intermediate βœ… βœ… ❌ βœ…
Day - 15 - Beginner βœ… βœ… ❌ βœ…
Day - 15 - Intermediate βœ… ❌ ❌ βœ…
Day - 16 - Beginner βœ… βœ… ❌ βœ…
Day - 16 - Intermediate ❌ ❌ ❌ ❌
Day - 17 - Beginner ❌ ❌ ❌ ❌
Day - 17 - Intermediate ❌ ❌ βœ… ❌
Day - 18 - Beginner βœ… ❌ ❌ ❌
Day - 18 - Intermediate ❌ ❌ ❌ ❌
Day - 19 - Beginner βœ… ❌ ❌ ❌
Day - 19 - Intermediate ❌ ❌ ❌ ❌
Day - 20 - Beginner βœ… ❌ ❌ ❌
Day - 20 - Intermediate ❌ ❌ ❌ ❌
Day - 21 - Beginner βœ… ❌ ❌ ❌
Day - 21 - Intermediate ❌ ❌ ❌ ❌
Day - 22 - Beginner βœ… ❌ ❌ ❌
Day - 22 - Intermediate βœ… ❌ ❌ ❌
Day - 23 - Beginner βœ… ❌ ❌ ❌
Day - 23 - Intermediate ❌ ❌ ❌ ❌
Day - 24 - Beginner βœ… ❌ ❌ ❌
Day - 24 - Intermediate ❌ ❌ ❌ ❌

After that, I will not update the readme file; I will just upload the programs to the C++ folder.



Day-01

Tasks for Day 01:
  • Recently, Chef visited his doctor. The doctor advised Chef to drink at least 2000 ml of water each day.

    Chef drank X ml of water today. Determine if Chef followed the doctor's advice or not.

    Input Format:

    • The first line contains a single integer T β€” the number of test cases. Then the test cases follow.

    • The first and only line of each test case contains one integer X β€” the amount of water Chef drank today. Output Format:

    • For each test case, output YES if Chef followed the doctor's advice of drinking at least 2000 ml of water. Otherwise, output NO.

    • You may print each character of the string in uppercase or lowercase (for example, the strings YES, yEs, yes, and yeS will all be treated as identical).

    Constraints:

    • 1 <= T <= 2000
    • 1 <= X <= 4000

    Explanation: Test case 1: Chef followed the doctor's advice since he drank 2999 ml of water which is >=2000 ml.

    Test case 2: Chef did not follow the doctor's advice since he drank 1450 ml of water which is < 2000 ml.

    Test case 3: Chef followed the doctor's advice since he drank 2000 ml of water which is >= 2000 ml.

  • For more details, You can find the full problem description on CodeChef's website: Water Consumption Problem Description.

    Solution/Codes

  • C++
  • Python
  • JavaScript
  • Golang
  • Here's an example of using the Python programming language:

    T = int(input())
    for _ in range(T):
        X = int(input())
        if X >= 2000:
            print("YES")
        else:
            print("NO")
    Images Day 01 Image

    πŸ” Back to Table



    Day-02

    Tasks for Day 02:
    • Chef has X 5 rupee coins and Y 10 rupee coins. Chef goes to a shop to buy chocolates for Chefina where each chocolate costs Z rupees. Find the maximum number of chocolates that Chef can buy for Chefina.
    • Input Format:
      • The first line contains a single integer T β€” the number of test cases. Then the test cases follow.
      • The first and only line of each test case contains three integers X, Y, and Z β€” the number of 5 rupee coins, the number of 10 rupee coins, and the cost of each chocolate.
    • Output Format:
      • For each test case, output the maximum number of chocolates that Chef can buy for Chefina.
    • Constraints:
      • 1 ≀ T ≀ 100
      • 1 ≀ X, Y, Z ≀ 1000
    • Sample 1:
      • Input
      • Output
      • 4
      • 10 10 10
      • 3 1 8
      • 8 1 3
      • 4 4 1000
      • Explanation:
      • Test case 1: Chef has 10β‹…5+10β‹…10=150 rupees in total. Since each chocolate costs 10 rupees, Chef can spend all 150 rupees and buy 15 chocolates for Chefina.
      • Test case 2: Chef has 3β‹…5+1β‹…10=25 rupees in total. Since each chocolate costs 8 rupees, Chef can buy a maximum of 3 chocolates for Chefina, leaving him with 1 rupee.
      • Test case 3: Chef has 8β‹…5+1β‹…10=50 rupees in total. Since each chocolate costs 3 rupees, Chef can buy a maximum of 16 chocolates for Chefina, leaving him with 2 rupees.
      • Test case 4: Chef has 4β‹…5+4β‹…10=60 rupees in total. Since each chocolate costs 1000 rupees, Chef can buy no chocolate for Chefina, leaving him with 60 rupees.

    For more details, You can find the full problem description on CodeChef's website: Chef and Chocolates Problem Description.

    Solution/Codes

  • C++
  • Python
  • JavaScript
  • Golang
  • Here's an example of using the Golang programming language:

    package main
    
    import "fmt"
    
    func main() {
        var T, X, Y, Z int
        fmt.Scan(&T)
        for i := 0; i < T; i++ {
            fmt.Scan(&X, &Y, &Z)
            totalRupees := X*5 + Y*10
            maxChocolates := totalRupees / Z
            fmt.Println(maxChocolates)
        }
    }
    Images Day 02 Image

    πŸ” Back to Table



    Day-03

    Tasks for Day 03:
    • Problem

      Chef's coding class is very famous in Chefland. This year X students joined his class, and each student will require one chair to sit on. Chef already has Y chairs in his class. Determine the minimum number of new chairs Chef must buy so that every student is able to get one chair to sit on.

    • Input Format

      The first line contains a single integer T β€” the number of test cases. Then the test cases follow.

      The first and only line of each test case contains two integers X and Y β€” the number of students in the class and the number of chairs Chef already has.

    • Output Format

      For each test case, output the minimum number of extra chairs Chef must buy so that every student gets one chair.

    • Constraints

      1 ≀ T ≀ 1000

      0 ≀ X, Y ≀ 100

    • Sample 1:
      • Input

        4

        20 14

        41 41

        35 0

        50 100

      • Output

        6

        0

        35

        0

      • Explanation

        Test case 1: There are 20 students in the class, and Chef has 14 chairs already. Therefore Chef must buy 6 more chairs.

        Test case 2: There are 41 students in the class, and Chef already has exactly 41 chairs. Therefore Chef does not need to buy any more chairs.

        Test case 3: There are 35 students in the class, and Chef has no chairs initially. Therefore Chef must buy 35 chairs.

    For more details, You can find the full problem description on CodeChef's website: Chairs Requirement Problem Description.

    Solution/Codes

  • C++
  • Python
  • JavaScript
  • Golang
  • Here's an example of using the JavaScript programming language:

    const readline = require("readline");
    
    const rl = readline.createInterface({
      input: process.stdin,
      output: process.stdout,
    });
    
    let T;
    let testCases = [];
    
    rl.question("", (t) => {
      T = parseInt(t);
      readInput();
    });
    
    function readInput() {
      if (testCases.length < T) {
        rl.question("", (input) => {
          const [X, Y] = input.split(" ").map(Number);
          testCases.push({ X, Y });
          readInput();
        });
      } else {
        processInput();
      }
    }
    
    function processInput() {
      for (let i = 0; i < T; i++) {
        const { X, Y } = testCases[i];
        const extraChairs = Math.max(0, X - Y);
        console.log(extraChairs);
      }
      rl.close();
    }
    Images Day 03 Image

    πŸ” Back to Table



    Day-04 - Beginner

    Today's Beginner problem:
    • Chef has started working at the candy store. The store has 100 chocolates in total.
    • Chef’s daily goal is to sell X chocolates. For each chocolate sold, he will get 1 rupee. However, if Chef exceeds his daily goal, he gets 2 rupees per chocolate for each extra chocolate.
    • If Chef sells Y chocolates in a day, find the total amount he made.
    • Input Format:
      • The first line of input will contain a single integer T, denoting the number of test cases.
      • Each test case consists of two space-separated integers X and Y β€” the daily goal of Chef and the number of chocolates he actually sells.
    • Output Format:
      • For each test case, output on a new line the total amount Chef made in a day.
    • Constraints:
      • 1 ≀ T ≀ 100
      • 1 ≀ X, Y ≀ 10
    • Sample 1:
      • Input

        4

        3 1

        5 5

        4 7

        2 3

      • Output

        1

        5

        10

        4

      • Explanation:

        Test case 1: Chef's daily goal was 3. Since he sold only 1 chocolate, he'll get only 1 rupee.

        Test case 2: Chef's daily goal was 5. Since he sold 5 chocolates, he'll get 5 rupees.

        Test case 3: Chef's daily goal was 4. Since he sold 7 chocolates, he'll get 4 rupees for the 4 chocolates as his daily goal and 2 rupees per chocolate for the extra 3 chocolates. The total amount he gets is 4 + 3 * 2 = 10.

        Test case 4: Chef's daily goal was 2. Since he sold 3 chocolates, he'll get 2 rupees for the 2 chocolates as his daily goal and 2 rupees per chocolate for the extra 1 chocolate. The total amount he gets is 2 + 1 * 2 = 4.

    For more details, You can find the full problem description on CodeChef's website: Candy Store Problem Description.

    Solution/Codes

  • C++
  • Python
  • JavaScript
  • Golang
  • Here's an example of using the C++ programming language:

    #include <iostream>
    using namespace std;
    
    int main() {
        int t;
        cin >> t;
        while (t--) {
            int x, y;
            cin >> x >> y;
            if (x >= y) {
                cout << y;
            } else {
                cout << x + 2 * (y - x);
            }
            cout << endl;
        }
        return 0;
    }
    Images Day 04 Image Beginner

    πŸ” Back to Table



    Day-04 - Intermediate

    Today's Intermediate problem:
  • Problem Name: "Hare and Tortoise Race"
  • Problem Description: The tortoise and the hare decide to run a race, yet again. This time around, however, the hare has gotten a bit smarter! The racetrack is a straight line, 𝐿 meters long. The tortoise moves at 𝑉1 meters per second, while the hare moves at 𝑉2 meters per second. It is known that 𝑉1 < 𝑉2, that is, the hare is strictly faster. The hare still wants to be a bit lazy, so it decides to give the tortoise a headstart β€” the hare will wait for an integer number of seconds before starting to run. Unfortunately, the animals' measuring devices aren't up to par β€” they can only measure in integer seconds, and will round up β€” so for example...
  • Input Format: The first line of input will contain a single integer 𝑇, denoting the number of test cases. The first and only line of each test case contains three space-separated integers 𝐿, 𝑉1, and 𝑉2 β€” the length of the racetrack, the tortoise's speed, and the hare's speed.
  • Output Format: For each test case, output on a new line the longest time the hare can wait, while still being able to win the race.
  • Constraints:
    • 1 ≀ 𝑇 ≀ 10,000
    • 1 ≀ 𝐿 ≀ 1,000
    • 1 ≀ 𝑉1 < 𝑉2 ≀ 1,000
  • Sample Input:
          5
          10 2 3
          10 2 4
          15 3 5
          8 1 20
          14 5 6
        
  • Sample Output:
          0
          1
          1
          6
          -1
        
  • Explanation: Test case 1: Here, 𝐿 = 10, 𝑉1 = 2, 𝑉2 = 3. The tortoise takes 5 seconds to finish the race, while the hare takes 3.33 seconds; which rounds up to 4. So, the hare cannot wait at all before starting.
  • For more details, You can find the full problem description on CodeChef's website: Work Smarter, Not Harder Problem Description.

    Solution/Codes

  • C++
  • Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the C++ programming language:

    #include <iostream>
    #include <math.h>
    #include <iomanip>
    using namespace std;
    
    int main() {
        int t;
        float L, v1, v2;
        cin >> t;
        while (t--) {
            cin >> L >> v1 >> v2;
            setprecision(3);
            int t1 = ceil(L / v1);
            int t2 = ceil(L / v2);
            if (t1 > t2) {
                if (t1 == t2 + 1)
                    cout << "0" << endl;
                else
                    cout << t1 - t2 - 1 << endl;
            } else if (t1 == t2)
                cout << "-1" << endl;
        }
        return 0;
    }
    Images Day 04 Image Intermediate

    πŸ” Back to Table



    Day-05 - Beginner

    Today's Beginner problem:
  • Problem: Chef's phone shows a Battery Low notification if the battery level is 15% or less.
  • Input Format:
    • The first line will contain T, the number of test cases.
    • Each test case contains a single line of input, an integer X, denoting the battery level of the phone.
  • Output Format:
    • For each test case, output in a single line "Yes" if the battery level is 15% or below. Otherwise, print "No".
  • Constraints:
    • 1 ≀ T ≀ 100
    • 1 ≀ X ≀ 100
  • Sample Input:
          3
          15
          3
          65
        
  • Sample Output:
          Yes
          Yes
          No
        
  • Explanation:
    • Test Case 1: The battery level is 15%. Thus, it would show a battery low notification.
    • Test Case 2: The battery level is 3%, which is less than 15%. Thus, it would show a battery low notification.
    • Test Case 3: The battery level is 65%, which is greater than 15%. Thus, it would not show a battery low notification.
  • For more details, You can find the full problem description on CodeChef's website: Battery Low Problem Description.

    Solution/Codes

  • C++
  • Python
  • JavaScript
  • Golang
  • Here's an example of using the Python programming language:

    t = int(input())
    for _ in range(t):
        x = int(input())
        if x <= 15:
            print("Yes")
        else:
            print("No")
    Images Day 05 Image Beginner

    πŸ” Back to Table



    Day-05 - Intermediate

    Today's Intermediate problem:
  • Problem: You and your friend are playing a game with hoops. There are N hoops (where N is odd) in a row. You jump into hoop 1, and your friend jumps into hoop N. Then you jump into hoop 2, and after that, your friend jumps into hoop (N-1), and so on. The process ends when someone cannot make the next jump because the hoop is occupied by the other person. Find the last hoop that will be jumped into.
  • Input Format:
    • The first line contains an integer T, the number of test cases. Then the test cases follow.
    • Each test case contains a single line of input, a single integer N.
  • Output Format:
    • For each testcase, output in a single line the answer to the problem.
  • Constraints:
    • 1 ≀ T ≀ 10^5
    • 1 ≀ N < 2 * 10^5 (N is odd)
  • Sample Input:
          2
          1
          3
        
  • Sample Output:
          1
          2
        
  • Explanation:
    • Test Case 1: Since there is only 1 hoop, that's the only one to be jumped into.
    • Test Case 2: The first player jumps into hoop 1. The second player jumps into hoop 3 and finally the first player jumps into hoop 2. Then the second player cannot make another jump, so the process stops.
  • For more details, You can find the full problem description on CodeChef's website: Hoop Jump Problem Description.

    Solution/Codes

  • C++
  • Python
  • ❌ JavaScript
  • Golang
  • Here's an example of using the Python programming language:

    t = int(input())
    for _ in range(t):
        n = int(input())
        print((n + 1) // 2)
    Images Day 05 Image Intermediate

    πŸ” Back to Table



    Day-06 - Beginner

    Today's Beginner problem:
  • Problem Name: Minimum Cars for Friends
  • Description: A single car can accommodate at most 4 people. N friends want to go to a restaurant for a party. Find the minimum number of cars required to accommodate all the friends.
  • Input Format:
    • The first line contains a single integer T, the number of test cases. Then the test cases follow.
    • Each test case contains a single line of input, a single integer N - denoting the number of friends.
  • Output Format:
    • For each test case, output the minimum number of cars required to accommodate all the friends.
  • Constraints:
    • 1 ≀ T ≀ 1000
    • 2 ≀ N ≀ 1000
  • Sample Input:
          4
          4
          2
          7
          98
        
  • Sample Output:
          1
          1
          2
          25
        
  • Explanation:
    • Test Case 1: There are only 4 friends and a single car can accommodate 4 people. Thus, only 1 car is required.
    • Test Case 2: There are only 2 friends and a single car can accommodate 4 people. Thus, only 1 car is required.
    • Test Case 3: There are 7 friends and 2 cars can accommodate 8 people. Thus, 2 cars are required.
  • For more details, You can find the full problem description on CodeChef's website: Minimum Cars required Problem Description.

    Solution/Codes

  • C++
  • Python
  • JavaScript
  • Golang
  • Here's an example of using the Golang programming language:

    package main
    
    import "fmt"
    
    func main() {
        var t int
        fmt.Scan(&t)
        for i := 0; i < t; i++ {
            var n int
            fmt.Scan(&n)
            fmt.Println((n + 3) / 4)
        }
    }
    Images Day 06 Image Beginner

    πŸ” Back to Table



    Day-06 - Intermediate

    Today's Intermediate problem:
  • Problem Name: Rearrange Digits for Multiple of 5
  • Description: Given a positive integer N, MoEngage wants you to determine if it is possible to rearrange the digits of N (in decimal representation) and obtain a multiple of 5. For example, when N = 108, we can rearrange its digits to construct 180 = 36 * 5, which is a multiple of 5.
  • Input Format:
    • The first line contains an integer T, the number of test cases. The description of the T test cases follows.
    • Each test case consists of two lines:
      • The first line contains a single integer D, the number of digits in N.
      • The second line consists of a string of length D, the number N (in decimal representation). It is guaranteed that the string does not contain leading zeroes and consists only of the characters 0, 1, ..., 9.
  • Output Format:
    • For each test case, print "Yes" if it is possible to rearrange the digits of N so that it becomes a multiple of 5. Otherwise, print "No".
  • Constraints:
    • 1 ≀ T ≀ 1000
    • 1 ≀ D ≀ 1000
    • 1 ≀ N < 10^1000
    • Sum of D over all test cases ≀ 1000
  • Sample Input:
          3
          3
          115
          3
          103
          3
          119
        
  • Sample Output:
          Yes
          Yes
          No
        
  • Explanation:
    • Test Case 1: The given number is already divisible by 5, therefore the answer is "Yes".
    • Test Case 2: We can obtain 310 = 62 * 5 by rearranging the digits of 103, so the answer is "Yes".
    • Test Case 3: The only numbers that can be obtained by rearranging the digits of 119 are {119, 191, 911}. None of these numbers are multiples of 5, so the answer is "No".
  • For more details, You can find the full problem description on CodeChef's website: Rearranging digits to get a multiple of 5 Problem Description.

    Solution/Codes

  • ❌ C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the JavaScript programming language:

    //❌
    Images Day 06 Image Intermediate

    πŸ” Back to Table



    Day-07 - Beginner

    Today's Beginner problem:
  • Problem: Chef categorises an Instagram account as spam if the following count of the account is more than 10 times the count of followers. Given the following and follower count of an account as X and Y respectively, find whether it is a spam account.
  • Input Format:
    • The first line of input will contain a single integer T, denoting the number of test cases.
    • Each test case consists of two space-separated integers X and Y β€” the following and follower count of an account, respectively.
  • Output Format:
    • For each test case, output on a new line, YES, if the account is spam and NO otherwise.
  • Constraints:
    • 1 ≀ T ≀ 100
    • 1 ≀ X, Y ≀ 100
  • Sample Input:
          4
          1 10
          10 1
          11 1
          97 7
        
  • Sample Output:
          NO
          NO
          YES
          YES
        
  • Explanation:
    • Test Case 1: The following count is 1 while the follower count is 10. Since the following count is not more than 10 times the follower count, the account is not spam.
    • Test Case 2: The following count is 10 while the follower count is 1. Since the following count is not more than 10 times the follower count, the account is not spam.
    • Test Case 3: The following count is 11 while the follower count is 1. Since the following count is more than 10 times the follower count, the account is spam.
    • Test Case 4: The following count is 97 while the follower count is 7. Since the following count is more than 10 times the follower count, the account is spam.
  • For more details, You can find the full problem description on CodeChef's website: Instagram Problem Description.

    Solution/Codes

  • C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the C++ programming language:

    #include <iostream>
    using namespace std;
    
    int main() {
        int t;
        cin >> t;
        while (t--) {
            int x, y;
            cin >> x >> y;
            cout << ((x > 10 * y) ? "YES" : "NO") << endl;
        }
        return 0;
    }
    Images Day 07 Image Beginner

    πŸ” Back to Table



    Day-07 - Intermediate

    Today's Intermediate problem:
  • Problem: The mayor of your city wants to throw a party and gather the favor of his people in different regions of the city. There are 3 distinct regions in the city, namely A, B, C, comprising of PA, PB, and PC number of people, respectively. However, people from region B are in conflict with people from regions A and C. Help the mayor invite the maximum number of people to the party without any conflicts.
  • Input Format:
    • The first line contains a single integer T, the number of test cases. Then the test cases follow.
    • For each test case, the first line contains three integers PA, PB, and PC, representing the number of people living in regions A, B, and C, respectively.
  • Output Format:
    • For each test case, output the maximum number of people that can be invited to the party without any conflicts.
  • Constraints:
    • 1 ≀ T ≀ 1000
    • 1 ≀ PA, PB, PC ≀ 1000
  • Sample Input:
          3
          2 3 4
          1 5 2
          8 8 8
        
  • Sample Output:
          6
          5
          16
        
  • Explanation:
    • Test Case 1: The mayor can invite all the people from regions A and C. So the maximum number of people invited is 6.
    • Test Case 2: The mayor can invite all the people from region B. So the maximum number of people invited is 5.
    • Test Case 3: The mayor can invite all the people from any one region without conflicts, so the maximum number of people invited is 16.
  • For more details, You can find the full problem description on CodeChef's website: Peaceful Party Problem Description.

    Solution/Codes

  • ❌ C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Python programming language:

        //❌
    Images Day 07 Image Intermediate

    πŸ” Back to Table



    Day-08 - Beginner

    Today's Beginner problem:
  • Problem: A geyser has a capacity of X litres of water, and a bucket has a capacity of Y litres of water. One person requires exactly 2 buckets of water to take a bath. Find the maximum number of people that can take a bath using water from one completely filled geyser.
  • Input Format:
    • The first line contains an integer T, the number of test cases. Then the test cases follow.
    • Each test case consists of a single line of input with two integers X and Y, representing the capacity of the geyser and the bucket, respectively.
  • Output Format:
    • For each test case, output the maximum number of people that can take a bath.
  • Constraints:
    • 1 ≀ T ≀ 1000
    • 1 ≀ X, Y ≀ 100
  • Sample Input:
          4
          10 6
          25 1
          100 10
          30 40
        
  • Sample Output:
          0
          12
          5
          0
        
  • Explanation:
    • Test Case 1: One bucket has a capacity of 6 litres. This means that one person requires 2 * 6 = 12 litres of water to take a bath. Since this is less than the total water present in the geyser, 0 people can take a bath.
    • Test Case 2: One bucket has a capacity of 1 litre. This means that one person requires 2 * 1 = 2 litres of water to take a bath. The total amount of water present in the geyser is 25 litres. Thus, 12 people can take a bath. Note that 1 litre of water would remain unused in the geyser.
    • Test Case 3: One bucket has a capacity of 10 litres. This means that one person requires 2 * 10 = 20 litres of water to take a bath. The total amount of water present in the geyser is 100 litres. Thus, 5 people can take a bath. Note that 0 litres of water would remain unused in the geyser after this.
  • For more details, You can find the full problem description on CodeChef's website: Bath in Winters Problem Description.

    Solution/Codes

  • C++
  • Python
  • ❌ JavaScript
  • Golang
  • Here's an example of using the Golang programming language:

    package main
    
    import "fmt"
    
    func main() {
        var T int
        fmt.Scan(&T)
        for i := 0; i < T; i++ {
            var X, Y int
            fmt.Scan(&X, &Y)
            maxPeople := X / (2 * Y)
            fmt.Println(maxPeople)
        }
    }
    Images Day 08 Image Beginner

    πŸ” Back to Table



    Day-08 - Intermediate

    Today's Intermediate problem:
  • Problem: Chef decided to buy a new tablet. His budget is B, so he cannot buy a tablet whose price is greater than B. Other than that, he only has one criterion β€” the area of the tablet's screen should be as large as possible. Of course, the screen of a tablet is always a rectangle.
  • Input:
    • The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
    • The first line of each test case contains two space-separated integers N and B.
    • N lines follow. For each i (1 ≀ i ≀ N), the i-th of these lines contains three space-separated integers Wi, Hi, and Pi.
  • Output:
    • For each test case, print a single line. If Chef cannot buy any tablet, it should contain the string "no tablet" (without quotes). Otherwise, it should contain a single integer β€” the maximum area of the screen of a tablet Chef can buy.
  • Constraints:
    • 1 ≀ T ≀ 100
    • 1 ≀ N ≀ 100
    • 1 ≀ B ≀ 1,000,000
    • 1 ≀ Wi, Hi ≀ 10,000
    • 1 ≀ Pi ≀ 1,000,000 for each valid i
  • Sample Input:
          3
          3 6
          3 4 4
          5 5 7
          5 2 5
          2 6
          3 6 8
          5 4 9
          1 10
          5 5 10
        
  • Sample Output:
          12
          no tablet
          25
        
  • Explanation:
    • Example case 1: The first tablet (with screen area 3 * 4 = 12) is the best option for Chef, since Chef cannot afford the second one, and the third one has a smaller screen.
    • Example case 2: Chef's budget is 6, but all tablets have higher prices, so Chef cannot buy any tablet.
    • Example case 3: The price of the only tablet is exactly equal to Chef's budget, so he is able to buy it.
  • For more details, You can find the full problem description on CodeChef's website: Buying New Tablet Problem Description.

    Solution/Codes

  • C++
  • Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Python programming language:

    T = int(input())
    for _ in range(T):
        N, B = map(int, input().split())
        max_area = -1
        for _ in range(N):
            W, H, P = map(int, input().split())
            if P <= B:
                area = W * H
                if area > max_area:
                    max_area = area
        if max_area == -1:
            print("no tablet")
        else:
            print(max_area)
    Images Day 08 Image Intermediate

    πŸ” Back to Table



    Day-09 - Beginner

    Today's Beginner problem:
  • Problem: The summer is at its peak in Chefland. Chef is planning to purchase a water cooler to keep his room cool. He has two options available:
    • Rent a cooler at the cost of X coins per month.
    • Purchase a cooler for Y coins.
    Chef wonders what is the maximum number of months for which he can rent the cooler such that the cost of renting is strictly less than the cost of purchasing it.
  • Input Format:
    • The first line of input will contain an integer T β€” the number of test cases. The description of T test cases follows.
    • The first and only line of each test case contains two integers X and Y, as described in the problem statement.
  • Output Format:
    • For each test case, output the maximum number of months for which he can rent the cooler such that the cost of renting is strictly less than the cost of purchasing it.
    • If Chef should not rent a cooler at all, output 0.
  • Constraints:
    • 1 ≀ T ≀ 1000
    • 1 ≀ X, Y ≀ 109
  • Sample Input:
          2
          5 12
          5 5
        
  • Sample Output:
          2
          0
        
  • Explanation:
    • Test case 1: Cost of renting the cooler = 5 coins per month. Cost of purchasing the cooler = 12 coins. So, Chef can rent the cooler for 2 months at the cost of 10 coins, which is strictly less than 12 coins.
    • Test case 2: Cost of renting the cooler = 5 coins per month. Cost of purchasing the cooler = 5 coins. If Chef rents the cooler for 1 month, it will cost 5 coins, which is not strictly less than the cost of purchasing it. So, Chef should not rent the cooler.
  • For more details, You can find the full problem description on CodeChef's website: The Cooler Dilemma 2 Problem Description.

    Solution/Codes

  • ❌ C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Python programming language:

        //❌
    Images Day 09 Image Beginner

    πŸ” Back to Table



    Day-09 - Intermediate

    Today's Intermediate problem:
  • Problem: Chef recently started working at ABC corporation. Let's number weekdays (Monday through Friday) by integers 1 through 5. For each valid i, the number of hours Chef spent working at the office on weekday i was Ai.
  • Input Format:
    • The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
    • The first and only line of each test case contains six space-separated integers A1, A2, A3, A4, A5, and P.
  • Output Format: For each test case, print a single line containing the string "Yes" if Chef has to work on weekends or "No" otherwise (without quotes).
  • Constraints:
    • 1 ≀ T ≀ 1,000
    • 0 ≀ Ai ≀ 24 for each valid i
    • 1 ≀ P ≀ 24
  • Sample Input:
          2
          14 10 12 6 18 2
          10 10 10 10 10 3
        
  • Sample Output:
          No
          Yes
        
  • Explanation:
    • Example case 1: Here, P=2, so the number of hours Chef has to work from home to handle his workload for days 1 through 5 is [28, 20, 24, 12, 36]. If he works for full 24 hours on each of the five weekdays, he finishes all the work, so he does not have to work on weekends.
    • Example case 2: No matter what Chef does, he will have to work on weekends.
  • For more details, You can find the full problem description on CodeChef's website: Lost Weekends Problem Description.

    Solution/Codes

  • C++
  • ❌ Python
  • ❌ JavaScript
  • Golang
  • Here's an example of using the Golang programming language:

    package main
    
    import "fmt"
    
    func main() {
        var T int
        fmt.Scan(&T)
        for t := 0; t < T; t++ {
            var A [5]int
            var P int
            for i := 0; i < 5; i++ {
                fmt.Scan(&A[i])
            }
            fmt.Scan(&P)
    
            totalHours := 0
            for i := 0; i < 5; i++ {
                totalHours += A[i]
            }
    
            if totalHours * P > 120 {
                fmt.Println("Yes")
            } else {
                fmt.Println("No")
            }
        }
    }
    Images Day 09 Image Intermediate

    πŸ” Back to Table



    Day-10 - Beginner

    Today's Beginner problem:
  • Problem: Valentine's Day is approaching, and Chef wants to buy some chocolates for someone special.
  • Input Format:
    • The first line will contain T, the number of test cases. Then the test cases follow.
    • Each test case contains a single line of input, two integers X and Y, as described in the problem statement.
  • Output Format:
    • For each test case, output the maximum number of chocolates Chef can buy.
  • Constraints:
    • 1 ≀ T ≀ 1000
    • 1 ≀ X, Y ≀ 100
  • Sample Input:
          4
          5 10
          16 5
          35 7
          100 1
        
  • Sample Output:
          0
          3
          5
          100
        
  • Explanation:
    • Test case 1: Chef has 5 rupees but the cost of one chocolate is 10 rupees. Therefore Chef cannot buy any chocolates.
    • Test case 2: Chef has 16 rupees and the cost of one chocolate is 5 rupees. Therefore Chef can buy at max 3 chocolates since buying 4 chocolates would cost 20 rupees.
    • Test case 3: Chef has 35 rupees and the cost of one chocolate is 7 rupees. Therefore Chef can buy at max 5 chocolates for 35 rupees.
    • Test case 4: Chef has 100 rupees and the cost of one chocolate is 1 rupee. Therefore Chef can buy at max 100 chocolates for 100 rupees.
  • For more details, You can find the full problem description on CodeChef's website: Valentine is Coming Problem Description.

    Solution/Codes

  • C++
  • Python
  • ❌ JavaScript
  • Golang
  • Here's an example of using the C++ programming language:

    #include <iostream>
    using namespace std;
    
    int main() {
        int T;
        cin >> T;
        while (T--) {
            int X, Y;
            cin >> X >> Y;
            cout << X / Y << endl;
        }
        return 0;
    }
    Images Day 10 Image Beginner

    πŸ” Back to Table



    Day-10 - Intermediate

    Today's Intermediate problem:
  • Problem: Chef has 3 bags that she wants to take on a flight. They weigh A, B, and C kgs respectively. She wants to check-in exactly two of these bags and carry the remaining one bag with her. The airline restrictions say that the total sum of the weights of the bags that are checked-in cannot exceed D kgs, and the weight of the bag which is carried cannot exceed E kgs. Find if Chef can take all three bags on the flight.
  • Input Format:
    • The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
    • Each testcase contains a single line of input, five space-separated integers A, B, C, D, E.
  • Output Format:
    • For each testcase, output in a single line "YES" if Chef can take all three bags with her, or "NO" if she cannot.
    • You may print each character of the string in uppercase or lowercase (e.g., "yEs", "yes", "Yes," and "YES" will all be treated as identical).
  • Constraints:
    • 1 ≀ T ≀ 36000
    • 1 ≀ A, B, C ≀ 10
    • 15 ≀ D ≀ 20
    • 5 ≀ E ≀ 10
  • Sample Input:
          3
          1 1 1 15 5
          8 7 6 15 5
          8 5 7 15 6
        
  • Sample Output:
          YES
          NO
          YES
        
  • Explanation:
    • Test case 1: Chef can check-in the first and second bag (since 1 + 1 ≀ 15) and carry the third bag with her (since 1 ≀ 5).
    • Test case 2: None of the three bags can be carried in hand without violating the airport restrictions.
    • Test case 3: Chef can check-in the first and the third bag (since 8 + 7 ≀ 15) and carry the second bag with her (since 5 ≀ 6).
  • For more details, You can find the full problem description on CodeChef's website: Airline Restrictions Problem Description.

    Solution/Codes

  • C++
  • Python
  • ❌ JavaScript
  • Golang
  • Here's an example of using the C++ programming language:

    #include <iostream>
    using namespace std;
    
    int main() {
        int T;
        cin >> T;
        while (T--) {
            int A, B, C, D, E;
            cin >> A >> B >> C >> D >> E;
            if ((A + B <= D && C <= E) || (B + C <= D && A <= E) || (A + C <= D && B <= E)) {
                cout << "YES" << endl;
            } else {
                cout << "NO" << endl;
            }
        }
        return 0;
    }
    Images Day 10 Image Intermediate

    πŸ” Back to Table



    Day-11 - Beginner

    Today's Beginner problem:
  • Problem: There is a cricket match in Chefland. Chef's team requires N runs to win in M overs.
  • Input Format:
    • The first line of input will contain a single integer T, denoting the number of test cases.
    • Each test case consists of two space-separated integers N and M β€” the number of runs required to win the game and the remaining number of overs.
  • Output Format:
    • For each test case, output on a new line, YES, if Chef's team can win the game. Otherwise, output NO.
    • You can print each character in uppercase or lowercase. For example NO, no, No, and nO are all considered identical.
  • Constraints:
    • 1 ≀ T ≀ 1000
    • 1 ≀ N ≀ 1000
    • 1 ≀ M ≀ 100
  • Sample Input:
          4
          500 20
          100 2
          30 1
          216 6
        
  • Sample Output:
          YES
          NO
          YES
          YES
        
  • Explanation:
    • Test case 1: Chef's team requires 500 runs to win. If they hit 6 runs on every ball for 13 overs, they will score 6 * 6 * 13 = 468 runs. In the 14th over, they can hit 6 runs in the first five balls and 2 runs in the sixth ball to get a total of 468 + 6 * 5 + 2 = 500 runs. Thus, Chef's team can win the game.
    • Test case 2: Since 100 is greater than the maximum runs that can be scored in 2 overs, it is not possible for Chef's team to win the game.
    • Test case 3: Since 30 is less than the maximum runs that can be scored in 1 over, it is possible for Chef's team to win the game.
    • Test case 4: Since 216 is equal to the maximum runs that can be scored in 6 overs, it is possible for Chef's team to win the game.
  • For more details, You can find the full problem description on CodeChef's website: Cricket Match Problem Description.

    Solution/Codes

  • ❌ C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the C++ programming language:

        //❌
    Images Day 11 Image Beginner

    πŸ” Back to Table



    Day-11 - Intermediate

    Today's Intermediate problem:
  • Problem: Chef has an array A of length N. In one operation, Chef can remove any one element from the array. Determine the minimum number of operations required to make all the elements same.
  • Input Format:
    • The first line of input will contain a single integer T, denoting the number of test cases.
    • Each test case consists of multiple lines of input.
    • The first line of each test case contains a single integer N β€”the length of Array A.
    • Next line contains N space-separated integers A1, A2, A3, …, An - denoting the array A.
  • Output Format:
    • For each test case, output the minimum number of operations required to make all the elements same.
  • Constraints:
    • 1 ≀ T ≀ 4000
    • 1 ≀ N ≀ 105
    • 1 ≀ Ai ≀ N
    • Sum of N over all test cases do not exceed 3 Γ— 105
  • Sample Input:
          4
          3
          3 3 3
          6
          1 3 2 1 2 2
          4
          1 2 1 2
          5
          1 3 2 4 5
        
  • Sample Output:
          0
          3
          2
          4
        
  • Explanation:
    • Test case 1: All the elements are already the same. Thus, we need to perform zero operations.
    • Test case 2: We remove the elements 1, 3, and 1 using three operations. The array becomes [2, 2, 2] where all elements are the same.
    • Test case 3: We remove the elements 1 and 1 using two operations. The array becomes [2, 2] where all elements are the same.
    • Test case 4: We remove the elements 1, 3, 2, and 5 using four operations. The array becomes [5].
  • For more details, You can find the full problem description on CodeChef's website: Remove Bad elements Problem Description.

    Solution/Codes

  • C++
  • Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the C++ programming language:

        //❌
    Images Day 11 Image Intermediate

    πŸ” Back to Table



    Day-12 - Beginner

    Today's Beginner problem:
  • Problem: Mario's bullet moves at X pixels per frame. He wishes to shoot a goomba standing Y pixels away from him. The goomba does not move. Find the minimum time (in seconds) after which Mario should shoot the bullet, such that it hits the goomba after at least Z seconds from now.
  • Input Format:
    • The first line of input will contain an integer T β€” the number of test cases. The description of T test cases follows.
    • Each test case consists of a single line of input, containing three space-separated integers X, Y, and Z.
  • Output Format:
    • For each test case, output in a single line the minimum time (in seconds) after which Mario should shoot the bullet, such that it hits the goomba after at least Z seconds from now.
  • Constraints:
    • 1 ≀ T ≀ 100
    • 1 ≀ X, Y, Z ≀ 100
    • X divides Y
  • Sample Input:
          3
          3 3 5
          2 4 1
          3 12 8
        
  • Sample Output:
          4
          0
          4
        
  • Explanation:
    • Test case 1: The speed of the bullet is 3 pixels per frame and the goomba is 3 pixels away from Mario. Thus, it would take 1 second for the bullet to reach the goomba. Mario wants the bullet to reach goomba after at least 5 seconds. So, he should fire the bullet after 4 seconds.
    • Test case 2: The speed of the bullet is 2 pixels per frame and the goomba is 4 pixels away from Mario. Thus, it would take 2 seconds for the bullet to reach the goomba. Mario wants the bullet to reach the goomba after at least 1 second. So, he should fire the bullet after 0 seconds. Note that, this is the minimum time after which he can shoot a bullet.
    • Test case 3: The speed of the bullet is 3 pixels per frame and the goomba is 12 pixels away from Mario. Thus, it would take 4 seconds for the bullet to reach the goomba. Mario wants the bullet to reach goomba after at least 8 seconds. So, he should fire the bullet after 4 seconds.
  • For more details, You can find the full problem description on CodeChef's website: Mario and Bullet Problem Description.

    Solution/Codes

  • C++
  • Python
  • ❌ JavaScript
  • Golang
  • Here's an example of using the C++ programming language:

    #include <iostream>
    using namespace std;
    
    int main() {
        int t;
        cin >> t;
        while (t--) {
            int x, y, z, a;
            cin >> x >> y >> z;
            a = y / x;
            if (a < z) {
                cout << z - a << endl;
            } else {
                cout << 0 << endl;
            }
        }
        return 0;
    }
    Images Day 12 Image Beginner

    πŸ” Back to Table



    Day-12 - Intermediate

    Today's Intermediate problem:
  • Problem: Bears love candies and games involving eating them. Limak and Bob play the following game. Limak eats 1 candy, then Bob eats 2 candies, then Limak eats 3 candies, then Bob eats 4 candies, and so on. Once someone can't eat what he is supposed to eat, he loses.
  • Input: The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. Each test case contains two integers A and B denoting the maximum possible number of candies Limak can eat and the maximum possible number of candies Bob can eat respectively.
  • Output: For each test case, output a single line containing one string β€” the name of the winner ("Limak" or "Bob").
  • Constraints:
    • 1 ≀ T ≀ 1000
    • 1 ≀ A, B ≀ 1000
  • Sample Input:
          10
          3 2
          4 2
          1 1
          1 2
          1 3
          9 3
          9 11
          9 12
          9 1000
          8 11
        
  • Sample Output:
          Bob
          Limak
          Limak
          Bob
          Bob
          Limak
          Limak
          Bob
          Bob
          Bob
        
  • Explanation: (Sample explanation provided in the problem statement)
  • For more details, You can find the full problem description on CodeChef's website: Bear and Candies 123 Problem Description.

    Solution/Codes

  • C++
  • Python
  • ❌ JavaScript
  • Golang
  • Here's an example of using the C++ programming language:

    #include <iostream>
    using namespace std;
    
    int main() {
        int T;
        cin >> T;
        while (T--) {
            int A, B;
            cin >> A >> B;
            int moves = 1;
            while (true) {
                if (moves % 2 == 1) {
                    A -= moves;
                    if (A < 0) {
                        cout << "Bob" << endl;
                        break;
                    }
                } else {
                    B -= moves;
                    if (B < 0) {
                        cout << "Limak" << endl;
                        break;
                    }
                }
                moves++;
            }
        }
        return 0;
    }
    Images Day 12 Image Intermediate

    πŸ” Back to Table



    Day-13 - Beginner

    Today's Beginner problem:
    • Problem: Chef is currently working for a secret research group called NEXTGEN. While the rest of the world is still in search of a way to utilize Helium-3 as a fuel, NEXTGEN scientists have been able to achieve 2 major milestones:
      1. Finding a way to make a nuclear reactor that will be able to utilize Helium-3 as a fuel
      2. Obtaining every bit of Helium-3 from the moon's surface
      Moving forward, the project requires some government funding for completion, which comes under one condition: to prove its worth, the project should power Chefland by generating at least A units of power each year for the next B years.
    • Input Format: The first line of input contains an integer T, the number of testcases. The description of T test cases follows. Each test case consists of a single line of input, containing four space-separated integers A, B, X, Y respectively.
    • Output Format: For each test case print on a single line the answer β€” Yes if NEXTGEN satisfies the government's minimum requirements for funding and No otherwise. You may print each character of the answer string in either uppercase or lowercase (for example, the strings "yEs", "yes", "Yes" and "YES" will all be treated as identical).
    • Constraints:
      • 1 ≀ T ≀ 1000
      • 1 ≀ A, B, X, Y ≀ 1000

    For more details, You can find the full problem description on CodeChef's website: Chef and NextGen Problem Description.

    Solution/Codes

  • C++
  • Python
  • ❌ JavaScript
  • Golang
  • Here's an example of using the Python programming language:

    t = int(input())
    for _ in range(t):
        a, b, x, y = map(int, input().split())
        if a * b <= x * y:
            print("Yes")
        else:
            print("No")
    Images Day 13 Image Beginner

    πŸ” Back to Table



    Day-13 - Intermediate

    Today's Intermediate problem:
    • Problem: Chef is working on a project for NEXTGEN. They need to power Chefland by generating at least A units of power each year for the next B years using Helium-3 from the moon.
    • Input Format: The first line contains an integer T, the number of test cases. Each test case contains four space-separated integers A, B, X, and Y.
    • Output Format: For each test case, print "Yes" if the project can generate enough power, or "No" otherwise.
    • Constraints:
      • 1 ≀ T ≀ 1000
      • 1 ≀ A, B, X, Y ≀ 1000

    For more details, You can find the full problem description on CodeChef's website: Odd Pairs Problem Description.

    Solution/Codes

  • ❌ C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Python programming language:

        // Your_code_here
    Images Day 13 Image Intermediate

    πŸ” Back to Table



    Day-14 - Beginner

    Today's Beginner problem:
    • Problem: Chef is currently standing at stair 0 and he wants to reach stair numbered X.
    • Input Format: The first line of input will contain a single integer T, denoting the number of test cases. Each test case consists of a single line of input containing two space-separated integers X and Y denoting the number of stairs Chef wants to reach and the number of stairs he can climb in one move.
    • Output Format: For each test case, output the minimum number of moves required by him to reach exactly the stair numbered X.
    • Constraints:
      • 1 ≀ T ≀ 500
      • 1 ≀ X, Y ≀ 100

    For more details, You can find the full problem description on CodeChef's website: X Jumps Problem Description.

    Solution/Codes

  • ❌ C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the C++ programming language:

        // Your_code_here
    Images Day 14 Image Beginner

    πŸ” Back to Table



    Day-14 - Intermediate

    Today's Intermediate problem:
    • Problem: There are three friends; let's call them A, B, C. They made the following statements:
      • A: "I have x Rupees more than B."
      • B: "I have y rupees more than C."
      • C: "I have z rupees more than A."
      You do not know the exact values of x, y, z. Instead, you are given their absolute values, i.e., |X|=|x|, |Y|=|y|, and |Z|=|z|. Note that x, y, z may be negative; "having -x rupees more" is the same as "having x rupees less".
    • Input Format: The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows. The first and only line of each test case contains three space-separated integers X, Y, and Z.
    • Output Format: For each test case, print a single line containing the string "yes" if the presented scenario is possible or "no" otherwise (without quotes).
    • Constraints:
      • 1 ≀ T ≀ 1,000
      • 1 ≀ X, Y, Z ≀ 1,000
    • Sample:
          Input
          2
          1 2 1
          1 1 1
          Output
          yes
          no
          

      Explanation:

      Example 1: One possible way to satisfy all conditions is: A has 10 rupees, B has 9 rupees, and C has 11 rupees. Therefore, we have x=1, y=-2, z=1.

      Example 2: There is no way for all conditions to be satisfied.

    For more details, You can find the full problem description on CodeChef's website: Three Friends Problem Description.

    Solution/Codes

  • C++
  • Python
  • ❌ JavaScript
  • Golang
  • Here's an example of using the Python programming language:

    package main
    
    import (
        "fmt"
    )
    
    func main() {
        var T int
        fmt.Scan(&T)
        for i := 0; i < T; i++ {
            var X, Y, Z int
            fmt.Scan(&X, &Y, &Z)
            if X == Y+Z || Y == Z+X || Z == X+Y {
                fmt.Println("yes")
            } else {
                fmt.Println("no")
            }
        }
    }
    Images Day 14 Image Intermediate

    πŸ” Back to Table



    Day-15 - Beginner

    Today's Beginner problem:
    • Problem: There are N cards on a table, out of which X cards are face-up and the remaining are face-down. In one operation, we can do the following: Select any one card and flip it (i.e., if it was initially face-up, after the operation, it will be face-down and vice versa). What is the minimum number of operations we must perform so that all the cards face in the same direction (i.e., either all are face-up or all are face-down)?
    • Input Format: The first line contains a single integer T β€” the number of test cases. Then the test cases follow. The first and only line of each test case contains two space-separated integers N and X β€” the total number of cards and the number of cards which are initially face-up.
    • Output Format: For each test case, output the minimum number of cards you must flip so that all the cards face in the same direction.
    • Constraints:
      • 1 ≀ T ≀ 5000
      • 2 ≀ N ≀ 100
      • 0 ≀ X ≀ N
    • Sample:
          Input
          4
          5 0
          4 2
          3 3
          10 2
      
      Output
      0
      2
      0
      2
      </pre>
      <p>Explanation:</p>
      <p>Test Case 1: All the cards are already facing down. Therefore we do not need to perform any operations.</p>
      <p>Test Case 2: 2 cards are facing up and 2 cards are facing down. Therefore we can flip the 2 cards which are initially facing down.</p>
      <p>Test Case 3: All the cards are already facing up. Therefore we do not need to perform any operations.</p>
      <p>Test Case 4: 2 cards are facing up and 8 cards are facing down. Therefore we can flip the 2 cards which are initially facing up.</p>
      

    For more details, You can find the full problem description on CodeChef's website: Flip the cards Problem Description.

    Solution/Codes

  • C++
  • Python
  • ❌ JavaScript
  • Golang
  • Here's an example of using the Cpp programming language:

    #include <iostream>
    using namespace std;
    
    int main() {
        int T;
        cin >> T;
        while (T--) {
            int N, X;
            cin >> N >> X;
            int flips = min(X, N - X);
            cout << flips << endl;
        }
        return 0;
    }
    Images Day 15 Image Beginner

    πŸ” Back to Table



    Day-15 - Intermediate

    Today's Intermediate problem:
    • Problem: Well-known investigative reporter Kim "Sherlock" Bumjun needs your help! Today, his mission is to sabotage the operations of the evil JSA. If the JSA is allowed to succeed, they will use the combined power of the WQS binary search and the UFDS to take over the world! But Kim doesn't know where the base is located. He knows that the base is on the highest peak of the Himalayan Mountains. He also knows the heights of each of the N mountains. Can you help Kim find the height of the mountain where the base is located?
    • Input Format: First line will contain T, the number of test cases. Then the test cases follow. The first line in each testcase contains one integer, N. The following N lines of each test case each contain one integer: the height of a new mountain.
    • Output Format: For each testcase, output one line with one integer: the height of the tallest mountain for that test case.
    • Constraints:
      • 1 ≀ T ≀ 10
      • 1 ≀ N ≀ 100000
      • 0 ≀ height of each mountain ≀ 10^9
    • Subtasks:
      • 100 points: No additional constraints.
    • Sample 1:
          Input
          1
          5
          4
          7
          6
          3
          1
          7
          

      Output

          7
          

    For more details, You can find the full problem description on CodeChef's website: Peak Finding Problem Description.

    Solution/Codes

  • C++
  • ❌ Python
  • ❌ JavaScript
  • Golang
  • Here's an example of using the Cpp programming language:

    #include <iostream>
    using namespace std;
    
    int main() {
        int T;
        cin >> T;
        while (T--) {
            int N;
            cin >> N;
            int tallest = -1;
            for (int i = 0; i < N; i++) {
                int height;
                cin >> height;
                tallest = max(tallest, height);
            }
            cout << tallest << endl;
        }
        return 0;
    }
    Images Day 15 Image Intermediate

    πŸ” Back to Table



    Day-16 - Beginner

    Today's Beginner problem:
    • Problem: Chef has N candies. He has to distribute them to exactly M of his friends such that each friend gets an equal number of candies, and each friend gets an even number of candies. Determine whether it is possible to do so.
    • Input Format: First line will contain T, the number of test cases. Then the test cases follow. Each test case consists of a single line of input, two integers N and M, the number of candies and the number of friends.
    • Output Format: For each test case, the output will consist of a single line containing "Yes" if Chef can distribute the candies as per the conditions and "No" otherwise. You may print each character of the string in uppercase or lowercase (for example, the strings "yes," "Yes," "yEs," and "YES" will all be treated as identical).
    • Constraints:
      • 1 ≀ T ≀ 1000
      • 1 ≀ N, M ≀ 1000
    • Sample 1:
          Input
          4
          9 3
          4 1
          4 2
          8 3
          

      Output

          No
          Yes
          Yes
          No
          

    For more details, You can find the full problem description on CodeChef's website: Candy Distribution Problem Description.

    Solution/Codes

  • C++
  • Python
  • ❌ JavaScript
  • Golang
  • Here's an example of using the Golang programming language:

    package main
    
    import (
        "fmt"
    )
    
    func main() {
        var T int
        fmt.Scan(&T)
        for i := 0; i < T; i++ {
            var N, M int
            fmt.Scan(&N, &M)
            if N%(2*M) == 0 {
                fmt.Println("Yes")
            } else {
                fmt.Println("No")
            }
        }
    }
    Images Day 16 Image Beginner

    πŸ” Back to Table



    Day-16 - Intermediate

    Today's Intermediate problem:
    • Problem: Chef has a total of N (Nβ‰₯4) chocolates. He decided to distribute them into three jars such that:
      • At least one jar has an odd number of chocolates.
      • Exactly two jars have the same number of chocolates.
      • Every jar has at least one chocolate.
      Find a valid distribution of chocolates for Chef.
    • Input Format: The first line of input will contain a single integer T, denoting the number of test cases. Each test case consists of a single integer N β€” the total number of chocolates.
    • Output Format: For each test case, output on a new line, three space-separated integers denoting the number of chocolates in each jar after distribution.
    • Constraints:
      • 1 ≀ T ≀ 10^5
      • 4 ≀ N ≀ 10^5
    • Sample 1:
          Input
          3
          4
          7
          11
          

      Output

          1 1 2
          1 3 3
          1 5 5
          

    For more details, You can find the full problem description on CodeChef's website: Chocolate Distribution Problem Description.

    Solution/Codes

  • ❌ C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Cpp programming language:

        // Your_code_here
    Images Day 16 Image Intermediate

    πŸ” Back to Table



    Day-17 - Beginner

    Today's Beginner problem:
    • Problem: There is a bus with 30 seats. The seats are numbered from 1 to 30, and the numbering is as depicted in this image.

      [Image depicting bus seat layout]

      As can be seen in the image, the bus is divided into two decks - The Lower deck, and the Upper deck, with 15 seats each. And some of the seats come as Single and some as Double. For example, Seats 1 and 2 are Double, whereas Seat 11 is a Single. You will be given a Seat number, and your job is to classify it as one of these 4 types:
      • Lower Single
      • Lower Double
      • Upper Single
      • Upper Double
    • Input Format: The first line of input will contain a single integer T, denoting the number of test cases. Each test case consists of a single integer N β€” the seat number.
    • Output Format: For each test case, output on a new line, the type of seat.
    • Constraints:
      • 1 ≀ T ≀ 100
      • 1 ≀ N ≀ 30
    • Sample 1:
          Input
          5
          6
          28
          16
          13
          10
          

      Output

          Lower Double
          Upper Single
          Upper Double
          Lower Single
          Lower Double
          

    For more details, You can find the full problem description on CodeChef's website: Bus Seat Numbering Problem Description.

    Solution/Codes

  • ❌ C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Python programming language:

        // Your_code_here
    Images Day 17 Image Beginner

    πŸ” Back to Table



    Day-17 - Intermediate

    Today's Intermediate problem:
    • Problem: CodeChef offers a feature called streak count. A streak is maintained if you solve at least one problem daily. Om and Addy actively maintain their streaks on CodeChef. Over a span of N consecutive days, you have observed the count of problems solved by each of them. Your task is to determine the maximum streak achieved by Om and Addy and find who had the longer maximum streak.
    • Input Format: The first line of input will contain a single integer T, denoting the number of test cases. Each test case consists of multiple lines of input. The first line of each test case contains an integer N β€” the number of days. The second line of each test case contains N space-separated integers, the ith of which is Ai, representing the problems solved by Om on the ith day. The third line of each test case contains N space-separated integers, the ith of which is Bi, representing the problems solved by Addy on the ith day.
    • Output Format: For each test case, output:
      • OM, if Om has a longer maximum streak than Addy;
      • ADDY, if Addy has a longer maximum streak than Om;
      • DRAW, if both have equal maximum streak.
      You may print each character in uppercase or lowercase.
    • Constraints:
      • 1 ≀ T ≀ 10^5
      • 1 ≀ N ≀ 10^5
      • 0 ≀ Ai, Bi ≀ 10^9
      • The sum of N over all test cases won't exceed 6 * 10^5.
    • Sample 1:
          Input
          3
          6
          1 7 3 0 2 13
          0 2 3 4 5 0
          3
          1 3 4
          3 1 2
          5
          1 2 3 0 1
          1 2 0 2 3
          

      Output

          Addy
          Draw
          Om
          

    For more details, You can find the full problem description on CodeChef's website: CodeChef Streak Problem Description.

    Solution/Codes

  • ❌ C++
  • Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Python programming language:

    def find_max_streak(N, om_solved, addy_solved):
        om_streak = 0
        addy_streak = 0
        max_om_streak = 0
        max_addy_streak = 0
    
        for i in range(N):
            if om_solved[i] > 0:
                om_streak += 1
            else:
                om_streak = 0
    
            if addy_solved[i] > 0:
                addy_streak += 1
            else:
                addy_streak = 0
    
            max_om_streak = max(max_om_streak, om_streak)
            max_addy_streak = max(max_addy_streak, addy_streak)
    
        if max_om_streak > max_addy_streak:
            return "OM"
        elif max_addy_streak > max_om_streak:
            return "ADDY"
        else:
            return "DRAW"
    
    T = int(input())
    for _ in range(T):
        N = int(input())
        om_solved = list(map(int, input().split()))
        addy_solved = list(map(int, input().split()))
        result = find_max_streak(N, om_solved, addy_solved)
        print(result)
    Images Day 17 Image Intermediate

    πŸ” Back to Table



    Day-18 - Beginner

    Today's Beginner problem:
    • Problem: Alice is playing Air Hockey with Bob. The first person to earn seven points wins the match. Currently, Alice's score is **A** and Bob's score is **B**. Charlie is eagerly waiting for his turn. Help Charlie by calculating the minimum number of points that will be further scored in the match before it ends.
    • Input Format:
      • The first line of input will contain an integer **T** β€” the number of test cases. The description of **T** test cases follows.
      • The first and only line of each test case contains two space-separated integers **A** and **B**, as described in the problem statement.
    • Output Format:
      • For each test case, output on a new line the minimum number of points that will be further scored in the match before it ends.
    • Constraints:
      • 1 ≀ **T** ≀ 50
      • 0 ≀ **A**, **B** ≀ 6
    • Sample Input and Output:
          Input
          4
          0 0
          2 5
          5 2
          4 3
      
      Output
      7
      2
      2
      3
      </pre>
      

    For more details, You can find the full problem description on CodeChef's website: Air Hockey Problem Description.

    Solution/Codes

  • C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Cpp programming language:

    #include <iostream>
    using namespace std;
    
    int main() {
        int T;
        cin >> T;
        while (T--) {
            int A, B;
            cin >> A >> B;
            cout << 7 - max(A, B) << endl;
        }
        return 0;
    }
    Images Day 18 Image Beginner

    πŸ” Back to Table



    Day-18 - Intermediate

    Today's Intermediate problem:
    • Problem: For a positive integer N, find the smallest integer X strictly greater than N such that digitSum(N) and digitSum(X) have different parity, i.e., one of them is odd, and the other is even.
    • Input Format: The first line contains an integer T, the number of test cases. The description of the T test cases follows. Each test case consists of a single line of input with a single integer, the number N.
    • Output Format: For each test case, print in a single line, an integer, the answer to the problem.
    • Constraints:
      • 1 ≀ T ≀ 1000
      • 1 ≀ N < 10^9
    • Sample 1:
          Input
          3
          123
          19
          509
          

      Output

          124
          21
          511
          

    For more details, You can find the full problem description on CodeChef's website: Digit Sum Parities Problem Description.

    Solution/Codes

  • ❌ C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Python programming language:

        // Your_code_here
    Images Day 18 Image Intermediate

    πŸ” Back to Table



    Day-19 - Beginner

    Today's Beginner problem:
    • Problem
      • There is a contest containing
        • 2 problems A and B.
        • 2 strong participants P and Q participated in the contest and solved both the problems.
        • P made AC submissions on problems A and B at time instants P_A and P_B respectively while Q made AC submissions on problems A and B at time instants Q_A and Q_B.
        • It is given that the time penalty is the minimum time instant at which a participant has solved both the problems. Also, the participant with the lower time penalty will have a better rank.
        • Determine which participant got the better rank or if there is a TIE.
    • Input Format
      • The first line will contain T, number of test cases. Then the test cases follow.
      • Each test case contains a single line of input, four integers P_A, P_B, Q_A, Q_B.
    • Output Format
      • For each test case, output P if P got a better rank, Q if Q got a better rank, TIE otherwise.
      • Note that output is case-insensitive i.e. P and p both are considered the same.
    • Constraints
      • 1 ≀ T ≀ 1000
      • 1 ≀ P_A, P_B, Q_A, Q_B ≀ 100
    • Sample 1:
      • Input
      • Output
      • 4
      • 5 10 2 12
      • 10 30 15 15
      • 20 8 4 20
      • 6 6 6 6
      • P
      • Q
      • TIE
      • TIE
      • Explanation:
        • Test Case 1:
          • Time penalty incurred by participant P = 10.
          • Time penalty incurred by participant Q = 12.
          • Since 10 < 12, P gets a better rank.
        • Test Case 2:
          • Time penalty incurred by participant P = 30.
          • Time penalty incurred by participant Q = 15.
          • Since 15 < 30, Q gets a better rank.
        • Test Case 3:
          • Time penalty incurred by participant P = 20.
          • Time penalty incurred by participant Q = 20.
          • Since 20 = 20, P and Q get the same rank (TIE).
        • Test Case 4:
          • Time penalty incurred by participant P = 6.
          • Time penalty incurred by participant Q = 6.
          • Since 6 = 6, P and Q get the same rank (TIE).

    For more details, You can find the full problem description on CodeChef's website: Determine the Winner Problem Description.

    Solution/Codes

  • C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the C++ programming language:

    #include <iostream>
    #include <string>
    using namespace std;
    
    int digitSum(int n) {
        int sum = 0;
        while (n > 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }
    
    int main() {
        int T;
        cin >> T;
    
        while (T--) {
            int N;
            cin >> N;
    
            int X = N + 1;
            while (true) {
                int sum_N = digitSum(N);
                int sum_X = digitSum(X);
    
                if (sum_N % 2 != sum_X % 2) {
                    cout << X << endl;
                    break;
                }
    
                X++;
            }
        }
    
        return 0;
    }
    Images Day 19 Image Beginner

    πŸ” Back to Table



    Day-19 - Intermediate

    Today's Intermediate problem:
    • Problem
      • Ram wants to generate some prime numbers for his cryptosystem. Help him please! Your task is to generate all prime numbers between two given numbers.
      • Warning: large Input/Output data, be careful with certain languages (though most should be OK if the algorithm is well designed)
    • Input Format
      • The first line contains t, the number of test cases (less than or equal to 10).
      • Followed by t lines which contain two numbers m and n (1 ≀ m ≀ n ≀ 1,000,000,000, n-m≀100,000) separated by a space.
    • Output Format
      • For every test case, print all prime numbers p such that m ≀ p ≀ n, one number per line. Separate the answers for each test case by an empty line.
    • Constraints
      • (1 ≀ m ≀ n ≀ 1,000,000,000, n-m≀100,000)
    • Sample 1:
      • Input
      • Output
      • 2
      • 1 10
      • 3 5
      • 2
      • 3
      • 5
      • 7
      • 3
      • 5

    For more details, You can find the full problem description on CodeChef's website: Prime Generator Problem Description.

    Solution/Codes

  • ❌ C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Python programming language:

        // Your_code_here
    Images Day 19 Image Intermediate

    πŸ” Back to Table



    Day-20 - Beginner

    Today's Beginner problem:
    • Problem
      • Chef is watching TV. The current volume of the TV is X. Pressing the volume up button of the TV remote increases the volume by 1 while pressing the volume down button decreases the volume by 1. Chef wants to change the volume from X to Y. Find the minimum number of button presses required to do so.
    • Input Format
      • The first line contains a single integer T - the number of test cases. Then the test cases follow.
      • The first and only line of each test case contains two integers X and Y - the initial volume and final volume of the TV.
    • Output Format
      • For each test case, output the minimum number of times Chef has to press a button to change the volume from X to Y.
    • Constraints
      • 1 ≀ T ≀ 100
      • 1 ≀ X, Y ≀ 100
    • Sample 1:
      • Input
      • Output
      • 2
      • 50 54
      • 12 10
      • 4
      • 2
      • Explanation:
        • Test Case 1: Chef can press the volume up button 4 times to increase the volume from 50 to 54.
        • Test Case 2: Chef can press the volume down button 2 times to decrease the volume from 12 to 10.

    For more details, You can find the full problem description on CodeChef's website: Volume Control Problem Description.

    Solution/Codes

  • C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Cpp programming language:

    #include <iostream>
    #include <cmath>
    
    using namespace std;
    
    int main() {
        int T;
        cin >> T;
    
        while (T--) {
            int X, Y;
            cin >> X >> Y;
    
            int diff = abs(X - Y);
            cout << diff << endl;
        }
    
        return 0;
    }
    Images Day 20 Image Beginner

    πŸ” Back to Table



    Day-20 - Intermediate

    Today's Intermediate problem:
    • Problem
      • N candidates (numbered from 1 to N) join Chef's firm. The first 5 candidates join on the first day, and then, on every subsequent day, the next 5 candidates join in.
      • For example, if there are 12 candidates, candidates numbered 1 to 5 will join on day 1, candidates numbered 6 to 10 on day 2, and the remaining 2 candidates will join on day 3.
      • Candidate numbered K decided to turn down his offer and thus, Chef adjusts the position by shifting up all the higher numbered candidates. This leads to a change in the joining day of some of the candidates.
    • Input Format
      • First line will contain T, number of test cases. Then the test cases follow.
      • Each test case consists of a single line of input, two space-separated integers N and K denoting the number of candidates and the candidate who turned down the offer.
    • Output Format
      • For each test case, output a single integer denoting the number of candidates whose joining day will be changed.
    • Constraints
      • 1 ≀ T ≀ 1000
      • 2 ≀ N ≀ 1000
      • 1 ≀ K ≀ N
    • Sample 1:
      • Input
      • Output
      • 4
      • 7 3
      • 6 6
      • 2 1
      • 14 2
      • 1
      • 0
      • 0
      • 2
      • Explanation:
        • Test case 1: The original joining day of each candidate is given as [1, 1, 1, 1, 1, 2, 2] but as candidate 3 turns down his offer, the new joining days are now [1, 1, NA, 1, 1, 1, 2]. Candidate numbered 6 is the only one to have his joining day changed.
        • Test case 2: The original joining day of each candidate is given as [1, 1, 1, 1, 1, 2] but as candidate 6 turns down his offer, the new joining days are now [1, 1, 1, 1, 1, NA]. No candidate got his joining day changed.
        • Test case 3: The original joining day of each candidate is given as [1, 1] but as candidate 1 turns down his offer, the new joining days are now [NA, 1]. No candidate got his joining day changed.
        • Test case 4: The original joining day of each candidate is given as [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3] but as candidate 2 turns down his offer, the new joining days are now [1, NA, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3]. Candidate numbered 6 and 11 are the only ones to have their joining days changed.

    For more details, You can find the full problem description on CodeChef's website: Joining Date Problem Description.

    Solution/Codes

  • ❌ C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Python programming language:

        // Your_code_here
    Images Day 20 Image Intermediate

    πŸ” Back to Table



    Day-21 - Beginner

    Today's Beginner problem:
    • Problem
      • Bob has an account in the Bobby Bank. His current account balance is W rupees.
      • Each month, the office in which Bob works deposits a fixed amount of X rupees to his account.
      • Y rupees is deducted from Bob's account each month as bank charges.
      • Find his final account balance after Z months. Note that the account balance can be negative as well.
    • Input Format
      • The first line will contain T, the number of test cases. Then the test cases follow.
      • Each test case consists of a single line of input, containing four integers W, X, Y, and Z β€” the initial amount, the amount deposited per month, the amount deducted per month, and the number of months.
    • Output Format
      • For each test case, output in a single line the final balance in Bob's account after Z months.
    • Constraints
      • 1 ≀ T ≀ 1000
      • 1 ≀ W, X, Y, Z ≀ 10^4
    • Sample 1:
      • Input
      • Output
      • 3
      • 100 11 1 10
      • 999 25 36 9
      • 2500 100 125 101
      • 200
      • 900
      • -25
      • Explanation:
        • Test case 1: Bob's current account balance is 100. At the end of each month, Bob gets Rs 11 and pays Rs 1, thus gaining 10 per month. Thus, at the end of 10 months, Bob will have 100 + 10 Γ— 10 = 200.
        • Test case 2: Bob's current account balance is 999. At the end of each month, Bob gets Rs 25 and pays Rs 36, thus losing 11 per month. Thus, at the end of 9 months, Bob will have 999 βˆ’ 11 Γ— 9 = 900.
        • Test case 3: Bob's current account balance is 2500. At the end of each month, Bob gets Rs 100 and pays Rs 125, thus losing 25 per month. Thus, at the end of 101 months, Bob will have 2500 βˆ’ 25 Γ— 101 = -25.

    For more details, You can find the full problem description on CodeChef's website: Bob at the Bank Problem Description.

    Solution/Codes

  • C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Cpp programming language:

    #include <iostream>
    using namespace std;
    
    int main() {
        int t;
        cin >> t;
    
        while (t--) {
            int w, x, y, z;
            cin >> w >> x >> y >> z;
    
            int final_balance = w + (x - y) * z;
            cout << final_balance << endl;
        }
    
        return 0;
    }
    Images Day 21 Image Beginner

    πŸ” Back to Table



    Day-21 - Intermediate

    Today's Intermediate problem:
    • Problem
      • Janmansh is at the fruit market to buy fruits for Chingari. There is an infinite supply of three different kinds of fruits with prices A, B, and C.
      • He needs to buy a total of X fruits having at least 2 different kinds of fruits. What is the least amount of money he can spend to buy fruits?
    • Input Format
      • The first line of the input contains a single integer T - the number of test cases. The description of T test cases follows.
      • The first and only line of each test case contains four space-separated integers X, A, B, C - the number of fruits to buy and the prices of the three different types of fruits, respectively.
    • Output Format
      • For each test case, output the least amount of money he can spend to buy fruits.
    • Constraints
      • 1 ≀ T ≀ 10^5
      • 2 ≀ X ≀ 1000
      • 1 ≀ A, B, C ≀ 100
    • Sample 1:
      • Input
      • Output
      • 2
      • 2 1 1 1
      • 3 4 3 2
      • 2
      • 7
      • Explanation:
        • Test case-1: He can buy any two fruits of different kinds for a total price of 2.
        • Test case-2: He can buy 1 fruit of price 3 and 2 fruits of price 2 for a total price of 7.

    For more details, You can find the full problem description on CodeChef's website: Janmansh at Fruit Market Problem Description.

    Solution/Codes

  • ❌ C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Python programming language:

        // Your_code_here
    Images Day 21 Image Intermediate

    πŸ” Back to Table



    Day-22 - Beginner

    Today's Beginner problem:
    • Problem
      • There are 100 questions in a paper. Each question carries +3 marks for a correct answer, -1 marks for an incorrect answer, and 0 marks for an unattempted question.
      • It is given that Chef received exactly X (0 ≀ X ≀ 100) marks. Determine the minimum number of problems Chef marked incorrect.
    • Input Format
      • First line will contain T, the number of test cases. Then the test cases follow.
      • Each test case consists of a single integer X, marks that Chef received.
    • Output Format
      • For each test case, output the minimum number of problems Chef marked incorrect.
    • Constraints
      • 1 ≀ T ≀ 100
      • 0 ≀ X ≀ 100
    • Sample 1:
      • Input
      • Output
      • 4
      • 0
      • 100
      • 32
      • 18
      • 0
      • 2
      • 1
      • 0
      • Explanation:
        • Test Case 1: It might be possible that Chef didn't attempt any question, in which case he didn't get any question incorrect.
        • Test Case 2: For the case when Chef got 34 questions correct and 2 questions incorrect, Chef marked the minimum number of incorrect questions.
        • Test Case 3: For the case when Chef got 11 questions correct and 1 question incorrect, Chef marked the minimum number of incorrect questions.
        • Test Case 4: For the case when Chef got 6 questions correct and no question incorrect, Chef marked the minimum number of incorrect questions.

    For more details, You can find the full problem description on CodeChef's website: High Accuracy Problem Description.

    Solution/Codes

  • C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Cpp programming language:

    #include <iostream>
    using namespace std;
    
    int main() {
        int T;
        cin >> T;
    
        while (T--) {
            int X;
            cin >> X;
            int incorrect = 0;
    
            if (X % 3 == 0) {
                incorrect = 0;
            } else if (X % 3 == 1) {
                incorrect = 2;
            } else {
                incorrect = 1;
            }
    
            cout << incorrect << endl;
        }
        return 0;
    }
    Images Day 22 Image Beginner

    πŸ” Back to Table



    Day-22 - Intermediate

    Today's Intermediate problem:
    • Problem
      • Write a program to obtain 2 numbers (A and B) and an arithmetic operator (C) and then design a calculator depending upon the operator entered by the user.
      • For example, if C = "+", you have to sum the two numbers.
      • If C = "-", you have to subtract the two numbers.
      • If C = "*", you have to print the product.
      • If C = "/", you have to divide the two numbers.
    • Input Format
      • First line will contain the first number A.
      • Second line will contain the second number B.
      • Third line will contain the operator C, that is to be performed on A and B.
    • Output Format
      • Output a single line containing the answer obtained by performing the operator on the numbers.
      • Your output will be considered correct if the difference between your output and the actual answer is not more than 10^-6.
    • Constraints
      • -1000 ≀ A ≀ 1000
      • -1000 ≀ B ≀ 1000
      • B β‰  0
      • C can only be one of these 4 operators: {"+", "-", "*", "/"}
    • Sample 1:
      • Input
      • Output
      • 8
      • 2
      • /
      • 4.0
    • Sample 2:
      • Input
      • Output
      • 5
      • 3
      • +
      • 8

    For more details, You can find the full problem description on CodeChef's website: Program Your Own CALCULATOR Problem Description.

    Solution/Codes

  • C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Cpp programming language:

    #include <iostream>
    using namespace std;
    
    int main() {
        double A, B, result;
    
        char opr;
    
        cin >> A;
        cin >> B;
        cin >> opr;
    
        switch (opr) {
            case '+':
                result = A + B;
                break;
            case '-':
                result = A - B;
                break;
            case '*':
                result = A * B;
                break;
            case '/':
                if (B == 0) {
                    cout << "Undefined" << endl;
                    return 0;
                }
                result = A / B;
                break;
            default:
                cout << "Invalid operator" << endl;
                return 0;
        }
    
        cout << fixed << result << endl;
        return 0;
    }
    Images Day 22 Image Intermediate

    πŸ” Back to Table



    Day-23 - Beginner

    Today's Beginner problem:
    • Problem: Alice, Bob, and Charlie want to buy a Netflix subscription. However, Netflix allows only two users to share a subscription. Given that Alice, Bob, and Charlie have specific amounts of money and the cost of a Netflix subscription, determine if any two of them can contribute to buy a subscription.
    • Input Format: The first line of input contains an integer T, the number of test cases. Each test case consists of four space-separated integers: A, B, C, and X β€” the amounts Alice, Bob, and Charlie have, and the cost of a Netflix subscription, respectively.
    • Output Format: For each test case, output "YES" if any two of them can contribute to buy a Netflix subscription, or "NO" otherwise. You may print the result in either uppercase or lowercase.
    • Constraints:
      • 1 ≀ T ≀ 1000
      • 1 ≀ A, B, C, X ≀ 100
    • Sample 1:
          Input
          4
          1 1 1 3
          2 3 1 5
          4 2 3 4
          2 1 4 7
          

      Output

          NO
          YES
          YES
          NO
          

    For more details, You can find the full problem description on CodeChef's website: Netflix Problem Description.

    Solution/Codes

  • C++
  • Python
  • JavaScript
  • Golang
  • Here's an example of using the Cpp programming language:

    #include <iostream>
    using namespace std;
    
    int main() {
        int T;
        cin >> T;
    
        while (T--) {
            int A, B, C, X;
            cin >> A >> B >> C >> X;
    
            if ((A + B >= X) || (A + C >= X) || (B + C >= X)) {
                cout << "YES" << endl;
            } else {
                cout << "NO" << endl;
            }
        }
    
        return 0;
    }
    Images Day 23 Image Beginner

    πŸ” Back to Table



    Day-23 - Intermediate

    Today's Intermediate problem:
    • Problem: Chef wants to estimate the skill level of participants in a coding competition. Each participant can be classified based on the number of problems they solved as follows:
      • 0 problems: Beginner
      • 1 problem: Junior Developer
      • 2 problems: Middle Developer
      • 3 problems: Senior Developer
      • 4 problems: Hacker
      • 5 problems: Jeff Dean
      Help Chef identify the programming level of each participant based on their problem-solving results.
    • Input:
      • The first line of the input contains a single integer N denoting the number of competitors.
      • N lines follow. The i-th of these lines contains five space-separated integers Ai, 1, Ai, 2, Ai, 3, Ai, 4, Ai, 5. The j-th of these integers (1 ≀ j ≀ 5) is 1 if the i-th contestant solved the j-th problem and 0 otherwise.
    • Output: For each participant, print a single line containing one string denoting Chef's classification of that contestant β€” one of the strings "Beginner," "Junior Developer," "Middle Developer," "Senior Developer," "Hacker," "Jeff Dean" (without quotes).
    • Constraints:
      • 1 ≀ N ≀ 5000
      • 0 ≀ Ai, j ≀ 1 for each valid i, j
    • Sample 1:
          Input
          7
          0 0 0 0 0
          0 1 0 1 0
          0 0 1 0 0
          1 1 1 1 1
          0 1 1 1 0
          0 1 1 1 1
          1 1 1 1 0
          

      Output

          Beginner
          Middle Developer
          Junior Developer
          Jeff Dean
          Senior Developer
          Hacker
          Hacker
          

    For more details, You can find the full problem description on CodeChef's website: Chef and Cook-Off Problem Description.

    Solution/Codes

  • ❌ C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Python programming language:

        // Your_code_here
    Images Day 23 Image Intermediate

    πŸ” Back to Table



    Day-24 - Beginner

    Today's Beginner problem:
    • Problem: Chef wants to gift C chocolates to Botswal on his birthday. However, he has only X chocolates with him. The cost of 1 chocolate is Y rupees. Find the minimum money in rupees Chef needs to spend so that he can gift C chocolates to Botswal.
    • Input Format: The first line will contain T, the number of test cases. Then the test cases follow. Each test case consists of a single line of input, three integers: C, X, and Y.
    • Output Format: For each test case, output in a single line the answer, the minimum money in rupees Chef needs to spend.
    • Constraints:
      • 1 ≀ T ≀ 100
      • 1 ≀ C ≀ 100
      • 0 ≀ X ≀ C
      • 1 ≀ Y ≀ 100
    • Sample 1:
          Input
          2
          7 5 5
          10 1 1
          

      Output

          10
          9
          

    For more details, You can find the full problem description on CodeChef's website: Chef and Chocolates Problem Description.

    Solution/Codes

  • C++
  • ❌ Python
  • ❌ JavaScript
  • ❌ Golang
  • Here's an example of using the Cpp programming language:

    using namespace std;
    
    int main() {
        int T;
        cin >> T;
    
        while (T--) {
            int C, X, Y;
            cin >> C >> X >> Y;
    
            int money_spent = 0;
    
            if (X >= C) {
                money_spent = 0;
            } else {
                int chocolates_needed = C - X;
                money_spent = chocolates_needed * Y;
            }
    
            cout << money_spent << endl;
        }
    
        return 0;
    }
    Images Day 24 Image Beginner

    πŸ” Back to Table



    Day-24 - Intermediate

    Today's Intermediate problem:
    • Problem: Chef has a number X whose value is initially 0. In one move, he can either increment X by 2 (X := X + 2) or decrement X by 1 (X := X - 1). Chef can perform at most Y moves. Find the number of distinct values X can have after performing at most Y moves.
    • Input Format: The first line of input contains a single integer T, denoting the number of test cases. The first and only line of each test case contains an integer Y, the maximum number of moves Chef can perform.
    • Output Format: For each test case, output the number of distinct values X can have after performing at most Y moves.
    • Constraints:
      • 1 ≀ T ≀ 1000
      • 0 ≀ Y ≀ 10^6
    • Sample 1:
                  Input
                  3
                  0
                  1
                  2
                  

      Output

                  1
                  3
                  6
                  

    For more details, You can find the full problem description on CodeChef's website: Plus 2 or Minus 1 Problem Description.

    Solution/Codes

  • C++
  • Python
  • JavaScript
  • Golang
  • Here's an example of using the Python programming language:

        // Your_code_here
    Images Day 24 Image Intermediate

    πŸ” Back to Table



    Contributors

    Ashish
    Ashish Singh