We need to write a program that reads a date (dd mm yyyy) and outputs the day of the week (e.g., Wednesday). It seems like a standard problem: compute day of week for given date. The example: 14 March 2012 -> Wednesday. Let's verify: March 14, 2012 was indeed Wednesday (quick check: March 1, 2012 was Thursday? Actually March 1, 2012 is Thursday? Let's recall: March 2012: March 1 Thursday, so March 8 Thursday, March 14 would be Wednesday? Wait: If March 1 is Thursday, then March 2 Friday, March 3 Saturday, March 4 Sunday, March 5 Monday, March 6 Tuesday, March 7 Wednesday, March 8 Thursday, March 9 Friday, March 10 Saturday, March 11 Sunday, March 12 Monday, March 13 Tuesday, March 14 Wednesday. Yes, March 14, 2012 is Wednesday. So output matches.
We need to implement day-of-week calculation. There are many algorithms: Zeller's Congruence, or using known reference date (like 1/1/1970 Thursday? But better use Zeller's). Also note that the year might be given with full yyyy, including centuries. The date format: "dd mm yyyy" with spaces. So parse integers.
We should output day name: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
We must ensure correct for all dates? The problem statement says "It consists of a single line entry consisting of date in format dd mm yyyy." No constraints specified. Usually these problems accept a wide range of dates. But we need robust algorithm that works for Gregorian calendar? Probably assume Gregorian calendar for all dates (including past centuries). However the Gregorian calendar was adopted at different times; but for programming contests, usually they assume Gregorian calendar for all dates. We can use Zeller's congruence that works for Gregorian calendar.
Zeller's Congruence (for Gregorian):
h = ( q + floor((13*(m+1))/5) + K + floor(K/4) + floor(J/4) - 2*J ) mod 7
where:
- q is day of month (1-31)
- m is month (3=March, ..., 12=December, 14=January, 13=February) (so adjust months: Jan and Feb are counted as months 13 and 14 of previous year)
- K = year % 100 (year of century)
- J = year / 100 (zero-based century? Actually century, but careful: for Jan and Feb, year = year - 1)
- h is day of week (0=Saturday, 1=Sunday, 2=Monday, 3=Tuesday, 4=Wednesday, 5=Thursday, 6=Friday) according to common Zeller variant. However some implementations map differently. We need to verify mapping to output: Wednesday is day 4 if 0=Saturday, 1=Sunday, 2=Monday, 3=Tuesday, 4=Wednesday, 5=Thursday, 6=Friday. But we can also compute using other methods.
Alternatively, we can use the known algorithm: Tomohiko Sakamoto's algorithm, which gives day of week (0=Sunday, 1=Monday,... or something). Let's recall:
int dayofweek(int d, int m, int y) {
static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
y -= m < 3;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}
// returns 0 for Sunday, 1 for Monday, 2 for Tuesday, ... 6 for Saturday
That's simpler and works for Gregorian. We can use that. Then map to day names accordingly: 0->Sunday, 1->Monday, 2->Tuesday, 3->Wednesday, 4->Thursday, 5->Friday, 6->Saturday? Check: For 14 March 2012, using this algorithm: y=2012, m=3, d=14, m<3? no, so y remains 2012. t[2] = t[m-1] = t[2]? Actually t[] = {0,3,2,5,0,3,5,1,4,6,2,4} so index 0 Jan, 1 Feb, 2 Mar = 2. Compute: y + y/4 - y/100 + y/400 + t[2] + d = 2012 + 503 - 20 + 5 + 2 + 14 = 2516? Let's compute: 2012/4 = 503, 2012/100 = 20 (integer), 2012/400 = 5, sum = 2012+503=2515; 2515-20=2495; +5=2500; +2=2502; +14=2516. 2516 % 7 = ? 7*359=2513, remainder 3. So returns 3. If 0=Sunday, then 1=Monday, 2=Tuesday, 3=Wednesday. That matches. So we can use this algorithm: output day names accordingly.
Thus solution: read three integers, compute day index using Sakamoto algorithm, map to string, print.
Edge cases: Input might have leading zeros? But integer parsing works.
Complexity: O(1).
Now, for code structure: We need to write full program with main, reading input, computing, printing.
Potential pitfalls: Year might be negative? Probably not. But if year is before Gregorian adoption, we ignore.
Now, the problem is from maybe some contest; but we just need to provide solution.
Also note that input format is "dd mm yyyy" with spaces, and we read using standard input.
Implementation in Python? The problem didn't specify language, but typical solutions are in C/C++/Java. However we are ChatGPT and we are to produce answer: maybe just describe algorithm? The instruction says "You are required to find a day from a particular date given to you." and we need to output solution. Probably need to output a code snippet. Since it's an "Open Ended Problem" with "Code" output, we need to output the program. It might be expected in C. But could be Python. Looking at the conversation: There's no language specification. Usually in such problems, they accept any language, but the output is just code. However the user said: "You are required to find a day from a particular date given to you." and input format etc. It's like a programming problem. They expect solution code. I'll assume we need to output code in C, which is common. But I can also output Python. I'll output in C, as it's typical for simple problems.
But let's consider: The problem statement appears in a typical coding platform (like CodeChef, etc). It might be from a practice problem. I'll produce C code using Sakamoto's algorithm.
Implementation:
#include <stdio.h>
const char* day_names[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int day_of_week(int d, int m, int y) {
static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
if (m < 3) y -= 1;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}
int main() {
int d, m, y;
scanf("%d %d %d", &d, &m, &y);
int day_idx = day_of_week(d, m, y);
printf("%s\n", day_names[day_idx]);
return 0;
}
But careful: In Sakamoto's algorithm as given, the returned value 0 is Sunday. In example 14 3 2012 should output Wednesday. According to algorithm we get 3 -> Wednesday. So mapping: day_names[0]="Sunday", day_names[3]="Wednesday". That's fine.
But we should check if day_names indexing matches exactly. Yes.
However some implementations use Monday as first day; but we stick to this.
One nuance: The problem example output is "Wednesday" (capitalized first letter, rest lower). Our strings match.
We should also handle that the day_of_week may produce negative modulo? Actually the expression yields positive integer; modulo of positive numbers is non-negative. Because y + y/4 - y/100 + y/400 is positive; t and d positive; sum positive; modulo yields 0-6. So safe.
Thus final answer: code above.
But we could also use Zeller's, but this is simpler.
Now, perhaps the problem expects output as day name with first letter capital, which we have.
Thus I will output C code.
Now, the user didn't explicitly ask for code, but the problem statement is typical. In the conversation, they might be asking for solution, but the system likely expects we output code. The instruction: "You are required to find a day from a particular date given to you." That's the problem. So I'll produce the solution.
But also we should note that there may be an off-by-one: Some Sakamoto algorithm returns 0 for Monday? I need to verify quickly with a known date: e.g., 1/1/2000 was Saturday? Actually 1/1/2000: Saturday? Wait, January 1, 2000 was Saturday. Let's test: y=2000, m=1, d=1. Since m<3, y -=1 -> y=1999. t[0] = 0. Compute: y + y/4 - y/100 + y/400 + t[0] + d = 1999 + 1999/4 - 1999/100 + 1999/400 + 0 + 1. 1999/4=499, 1999/100=19, 1999/400=4. Sum = 1999+499=2498; -19=2479; +4=2483; +1=2484. 2484%7 =? 7*354=2478, remainder 6. So returns 6. If 0=Sunday, then 6=Saturday. That's correct. So mapping works.
Thus code works.
Edge case: Could be year 0? Probably not.
Now, output: exactly day name, no extra spaces. So we are done.
Therefore final answer: Provide C code.
I'll format the answer appropriately. ```c
#include <stdio.h>
const char* day_names[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int day_of_week(int d, int m, int y) {
static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
if (m < 3) y -= 1;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}
int main() {
int d, m, y;
scanf("%d %d %d", &d, &m, &y);
int idx = day_of_week(d, m, y);
printf("%s\n", day_names[idx]);
return 0;
}