Practice

MODERATE

# EXPLANATION:

Input:

``````1
avcd02 tm11h ioy1996
``````

Output:

``````MM-DD-YYYY 11-02-1996 valid Saturday
MM-DD-YY 11-02-96 valid Saturday
DD-MM-YYYY 02-11-1996 valid Saturday
DD-MM-YY 02-11-96 valid Saturday
``````

Here, for the above input the no. of test cases is 1 i.e., P=1.

The given string (Q) is “avcd02 tm11h ioy1996”.

Note it is a string which is a collection of characters (words) with spaces between them. First “d/D” is searched and it is present in the first word “avcd02” followed by two digits hence the date becomes 02. Then “m/M” is searched and it is present in the second word “tm11h” followed by two digits hence the month becomes 11. Finally, “y/Y” is searched and it is present in the third word “ioy1996” followed by four digits hence the year becomes 1996.

The entered date is also valid. The corresponding day for the entered date is Saturday. So, the output will be:

MM-DD-YYYY 11-02-1996 valid Saturday

MM-DD-YY 11-02-96 valid Saturday

DD-MM-YYYY 02-11-1996 valid Saturday

DD-MM-YY 02-11-96 valid Saturday

# Test Cases:

1
Input :
1
avcd02tm11hioy1996
Output:
MM-DD-YYYY 11-02-1996 valid Saturday
MM-DD-YY 11-02-96 valid Saturday
DD-MM-YYYY 02-11-1996 valid Saturday
DD-MM-YY 02-11-96 valid Saturday

2
Input :
1
cdyaY1998t fgd7r hhmm06
Output:
MM-DD-YYYY 06-00-1998 invalid cannot be computed
MM-DD-YY 06-00-98 invalid cannot be computed
DD-MM-YYYY 00-06-1998 invalid cannot be computed
DD-MM-YY 00-06-98 invalid cannot be computed

3
Input :
1
tym4m04rdd01uoY2020
Output:
MM-DD-YYYY 04-01-2020 valid Wednesday
MM-DD-YY 04-01-20 valid Wednesday
DD-MM-YYYY 01-04-2020 valid Wednesday
DD-MM-YY 01-04-20 valid Wednesday

4
Input :
1
tym4m04 rdd01u oy2020xy
Output:
MM-DD-YYYY 04-01-2020 valid Wednesday
MM-DD-YY 04-01-20 valid Wednesday
DD-MM-YYYY 01-04-2020 valid Wednesday
DD-MM-YY 01-04-20 valid Wednesday

5
Input :
1
TTDDDD15 MMMMMM09 YYY2020YYY
Output:
MM-DD-YYYY 09-15-2020 valid Tuesday
MM-DD-YY 09-15-20 valid Tuesday
DD-MM-YYYY 15-09-2020 valid Tuesday
DD-MM-YY 15-09-20 valid Tuesday

6
Input :
1
DfmMMgM cvDdbb myyY
Output:
MM-DD-YYYY 00-00-0000 invalid cannot be computed
MM-DD-YY 00-00-00 invalid cannot be computed
DD-MM-YYYY 00-00-0000 invalid cannot be computed
DD-MM-YY 00-00-00 invalid cannot be computed