Posts

Showing posts from April, 2026

Codechef Problems: Missing Shoes (SHOM)

 Problem Statement:  Chef owns several pairs of shoes, unfortunately he has so many that he lost track of them! Each pair of shoes consists of one left shoe and one right shoe. Looking at his collection, Chef counts  L L  left shoes and  R R  right shoes. What's the minimum number of shoes Chef is missing? Input Format The only line of input will contain two space-separated integers  L L  and  R R  – the number of left shoes and right shoes, respectively. Output Format Output a single integer: the minimum number of shoes Chef is missing. Constraints 1 ≤ L , R ≤ 10 1 ≤ L , R ≤ 10 Solution:  Given,      L : Number of Left Shoes      R : Number of Right Shoes  To find: Minimum number of shoes Chef is missing  Problem background: A Shoe pair has 1 left shoe and 1 right shoe, Here we assume that we will not count the number of shoes which were missing in pairs (i.e., both left and right shoes are m...

Codechef Problems: Assignment Due (P1_175)

 Problem Statement:  You are eagerly awaiting for the upcoming Technex event organized by IIT BHU Varanasi! However, you also have an assignment due. The deadline for the assignment is in  Y Y  days, and it takes you  X X  days to complete it. Determine whether you can finish the assignment on or before the deadline. Input Format The input consists of two space-separated integers  X X  and  Y Y , where: X X  denotes the number of days required to complete the assignment. Y Y  denotes the number of days remaining until the deadline. Output Format Print  YES  if you can complete the assignment on or before the due date, otherwise print  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 ≤ X ≤ 100 1 ≤ X ≤ 100 1 ≤ Y ≤ 100 1 ≤ Y ≤ 100 Solution:  Given,    ...

Codechef Problems : Happy New Year! (NEWYEAR)

 Problem Statement:  Currently, it is  X : 00 X : 00  hours on December  31 s t 3 1 s t  and you are wondering how many hours are left till midnight. For the purposes of this problem, we use a  24 24  hour system. So,  X X  can range from  0 0  to  23 23 , and you need to tell the number of hours left till  00 : 00 00 : 00  of the next day. Input Format The first and only line of input contains a single integer  X X . Output Format For each test case, output on a new line the number of hours left till midnight Constraints 0 ≤ X ≤ 23 0 ≤ X ≤ 23 Solution:  Given, X : current time in hour on December 31st.  To Find: Remaining time for New year i.e., 0 hour of the next day  we know there are 24 hours in a day and present time is X hour  so time remaining for 0 hour next day is (24 - X)  Code Solution:  #include <bits/stdc++.h> using namespace std; int main() {     in...

Codechef Problems: Triangles (TRIANGLE7)

 Problem Statement:  It is well known fact in mathematics that the sum of the  3 3  angles in a triangle is  180 180  degrees. You had a triangle, but unfortunately you only remember the  1 s t 1 s t  and  2 n d 2 n d  angles of it, and you have forgotten the  3 r d 3 r d  one. Given that the first angle was  A A , and the second was  B B , can you figure out the third one? All angles are integers measured in degrees. Input Format The first and only line of input contains  2 2  integers -  A A  and  B B . Output Format Print a single integer - the measure of the  3 r d 3 r d  angle (in degrees). Constraints 1 ≤ A , B < 180 1 ≤ A , B < 180 A + B < 180 A + B < 180 Solution:  Given,      A : First Angle of Triangle      B : Second Angle of Triangle  To find,      C : Third angle of Triangle  By Angle Sum property of...