Sherlock Holmes received a strange note: Let's date!3485 djDkxh4hhGE 2984 akDfkkggEdsb s&hgsfdk d&Hyscvnm.The detective soon understood that the strange scrambling on the note was actually the date of the appointment on Thursday 14:04, because the first pair of identical uppercase letters (case sensitive) in the first two strings was the fourth letter D, representing Thursday; the second pair of identical characters was E, which was the fifth letter, GenerationThe 14th hour of the day of the table (so 0 to 23 o'clock of the day is represented by numbers 0 to 9 and capital letters A to N); the first pair of identical English letters s of the last two strings appears at the 4th position (counting from 0), representing the 4th minute.Now given two pairs of strings, help Holmes decode the time of the appointment.
Input format:
Input gives four non-empty, non-empty, and no longer than 60 strings on four lines.
Output format:
Output the time of an appointment on a line in the format DAY HH:MM, where DAY is the three-character abbreviation of a week, that is, MON for Monday, TUE for Tuesday, WED for Wednesday, THU for Thursday, FRI for Friday, SAT for Saturday, SUN for Sunday.Title entry ensures that each test has a unique solution.
Input sample:
3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm
Output sample:
THU 14:04Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm. It took him only a minute to figure out that those strange strings are actually referring to the coded time Thursday 14:04 -- since the first common capital English letter (case sensitive) shared by the first two strings is the 4th capital letter D, representing the 4th day in a week; the second common character is the 5th capital letter E, representing the 14th hour (hence the hours from 0 to 23 in a day are represented by the numbers from 0 to 9 and the capital letters from A to N, respectively); and the English letter shared by the last two strings is s at the 4th position, representing the 4th minute. Now given two pairs of strings, you are supposed to help Sherlock decode the dating time.
Input Specification:
Each input file contains one test case. Each case gives 4 non-empty strings of no more than 60 characters without white space in 4 lines.
Output Specification:
For each test case, print the decoded time in one line, in the format DAY HH:MM, where DAY is a 3-character abbreviation for the days in a week -- that is, MON for Monday, TUE for Tuesday, WED for Wednesday, THU for Thursday, FRI for Friday, SAT for Saturday, and SUN for Sunday. It is guaranteed that the result is unique for each case.
Sample Input:
3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm
Sample Output:
THU 14:04
#include<iostream> using namespace std; int convHH(char value){ if(value>='A'&&value<='N') return value-'A'+10; else return value-'0'; } string convDay(char value){ switch(value){ case 'A':return "MON"; case 'B':return "TUE"; case 'C':return "WED"; case 'D':return "THU"; case 'E':return "FRI"; case 'F':return "SAT"; case 'G':return "SUN"; } } int main() { string a,b,c,d; cin>>a>>b>>c>>d; int m=0; char DAY,HH; for(int i=0;i<a.length();i++,m++){ if(a[m]==b[m]&&(a[m]>='A'&&a[m]<='G')){/**Reduce range to A-G*/ DAY=a[m]; break; } } m++; for(int i=m;i<a.length();i++,m++){ if(a[m]==b[m]&&((a[m]>='A'&&a[m]<='N')||(a[m]>='0'&&a[m]<='9'))){ HH=a[m]; break; } } for(int i=0;i<c.length();i++){ if(c[i]==d[i]&&((c[i]>='A'&&c[i]<='Z')||(c[i]>='a'&&c[i]<='z'))){ m=i; break; } } cout<<convDay(DAY)<<" "; printf("%02d:%02d",convHH(HH),m); system("pause"); return 0; }