Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Vaccine Dates CodeChef Solution

Problem – Vaccine Dates CodeChef Solution

Chef has taken his first dose of vaccine D days ago. He may take the second dose no less than L days and no more than R days since his first dose.

Determine if Chef is too early, too late, or in the correct range for taking his second dose.

Input Format

  • First line will contain T, number of testcases. Then the testcases follow.
  • Each testcase contains of a single line of input, three integers D,L,R.

Output Format

For each test case, print a single line containing one string – “Too Early” (without quotes) if it’s too early to take the vaccine, “Too Late” (without quotes) if it’s too late to take the vaccine, “Take second dose now” (without quotes) if it’s the correct time to take the vaccine.

Constraints

  • 1≤T≤10^5
  • 1≤D≤10^9
  • 1≤LR≤10^9

Subtasks

  • Subtask 1 (100 points): Original constraints

Sample 1:

Input:
4
10 8 12 
14 2 10
4444 5555 6666 
8 8 12
Output:
Take second dose now
Too Late
Too Early
Take second dose now

Explanation:

Test case 1: The second dose needs to be taken within 8 to 12 days and since the Day 10 lies in this range, we can take the second dose now.

Test case 2: The second dose needs to be taken within 2 to 10 days since Day 14 lies after this range, it is too late now.

Test case 3: The second dose needs to be taken within 5555 to 6666 days and since the Day 4444 lies prior to this range, it is too early now.

Vaccine Dates CodeChef Solution in Java

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		    Scanner sc = new Scanner (System.in);
		    int t = sc.nextInt();
		    for(int i=0;i<t;i++)
		    {
		        int d = sc.nextInt();
		        int l = sc.nextInt();
		        int r = sc.nextInt();
		        if((d>=l)&&(d<=r))
		        System.out.println("Take second dose now");
		        else if(d<l)
		        System.out.println("Too Early");
		        else 
		        System.out.println("Too Late");
		    }
	}
}

Vaccine Dates CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int x ,y ,z;
	    cin>>x>>y>>z;
	    if(x>=y && x<=z){
	        std::cout << "Take second dose now" << std::endl;
	    }
	    else if (x<y){
	        std::cout << "Too Early" << std::endl;
	    }
	    else if (x>z){
	        std::cout << "Too Late" << std::endl;
	    }
	}
	return 0;
}

Vaccine Dates CodeChef Solution in Pyth 3

# cook your dish here
t=int(input())
for i in range(t):
    
    x,y,z=map(int,input().split())
    if y<=x and x<=z:
        print("Take second dose now")
    elif y>x:
        print("Too Early")
    else:
        print("Too Late")
Vaccine Dates CodeChef Solution Review:

In our experience, we suggest you solve this Vaccine Dates CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Vaccine Dates CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Vaccine Dates CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *