CODEIT03 - Play with Dates

no tags 

Problem Statement:

Given the date, month and year, find the day.

Input Specification:

The first line consists of an integer t, the number of test cases. Then for each test case there are three integers the date, month and year.

Output Specification:

For each test case print the day in words in a separate line (The first character should be capitalised followed by lowercase).

Input Constraints:

1 <= t <= 100

Date/month/year >= 11/1/2012

Date/month/year <= 31/12/3000

The given date will always be a valid date

Sample Input:

3

11 1 2012

12 1 2012

13 1 2012

Sample Output:

Wednesday

Thursday

Friday


hide comments
sw2022: 2023-11-16 03:01:43

@cegprakash Isn't there any invalid date? I use the Kim Larson F/A and output none when the date is invalid such that 29 2 2013 cost me 1 WA... When I delete this special judge to invalid dates and my program output Friday for previous sample, it got AC. Therefore, please check the test case and figure out if there is any invalid date in it.

Added by myself: My program runs well in https://www.spoj.com/problems/CLOCK1/ , so I think you shouldn't doubt the correctness of the F/A or the program.

Reply by author: There is no test case with 29 as the date for February month in the judge. You can add a check for the same to verify this if you have an AC solution. I initially created a simple generator to avoid these issues.

Last edit: 2024-03-06 16:58:22
adityad1998: 2018-07-01 19:47:05

Read Zeller’s Congruence if you want a O(1) solution. Interesting method.

Akshat Jain: 2016-06-25 13:09:53

nice ques...had to check with my phone's calendar to make sure I m getting the correct answer in all cases...ACC in one go...:p

dwij28: 2016-01-06 03:24:50

That awkward moment when you google the spellings of the days of the week just to make sure you don't get a WA for that. :P AC at one go, I calculated the days passed since 1/ 1/ 2012 in O(1) and calculated the weekday using the fact that 1/ 1/ 2012 was Sunday.

sumit suthar: 2015-11-15 08:36:01

Ac in one go ;)
concept of odd days ;)

Tim Wargon: 2015-10-21 13:25:07

now i will never forget the logic behind leap years :) AC !

Ajay Pilaniya: 2015-08-23 01:04:59

Problem is easy but implementation is hard

anuveshkothari: 2015-07-27 13:24:25

same logic.. WA in java ..accepted in C++..

vasayashwanth: 2015-07-22 15:20:25

too easy....check for leap years....

karthik1997: 2015-07-13 04:21:53

Acin 1st go :D 0.0s
Reminder: take care of input constraints and design your code . it is enough . no need to find the day from 01/01/0001 :p
i didnt use any algo but only bruteforce :) check it out for clarity :p

Last edit: 2022-06-23 20:24:18

Added by:cegprakash
Date:2012-01-09
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All