链接:https://www.nowcoder.com/questionTerminal/7335f56d49e946c2a7cd2a93661b293b
来源:牛客网
大侦探福尔摩斯接到一张奇怪的字条:“我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm”。大侦探很快就明白了,字条上奇怪的乱码实际上就是约会的时间“星期四 14:04”,因为前面两字符串中第1对相同的大写英文字母(大小写有区分)是第4个字母'D',代表星期四;第2对相同的字符是'E',那是第5个英文字母,代表一天里的第14个钟头(于是一天的0点到23点由数字0到9、以及大写字母A到N表示);后面两字符串第1对相同的英文字母's'出现在第4个位置(从0开始计数)上,代表第4分钟。现给定两对字符串,请帮助福尔摩斯解码得到约会的时间。
输入描述:
输入在4行中分别给出4个非空、不包含空格、且长度不超过60的字符串
输出描述:
在一行中输出约会的时间,格式为“DAY HH:MM”,其中“DAY”是某星期的3字符缩写,即MON表示星期一,TUE表示星期二,WED表示星期三,THU表示星期 四,FRI表示星期五,SAT表示星期六,SUN表示星期日。题目输入保证每个测试存在唯一解。
示例1
输入
3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm
输出
THU 14:04
方法一:
#Author:dachonghang
one, two, three, four = input(), input(), input(), input()
DAY = {'A':'MON','B':'TUE','C':'WED','D':'THU','E':'FRI','F':'SAT','G':'SUN'}
HH = {"0":"00","1":"01","2":"02","3":"03","4":"04","5":"05","6":"06","7":"07","8":"08","9":"09","A":"10","B":"11","C":"12","D":"13","E":"14","F":"15","G":"16","H":"17","I":"18","J":"19","K":"20","L":"21","M":"22","N":"23"}
alpha = [i for i in [range(65, 91), range(97, 123)]] #alpha[0] 大写 [1]小写
index = 0
date = ""
hh = ""
while True:
if one[index] == two[index]:
if date != "":
hh = HH[one[index]]
break
elif (ord(one[index]) in alpha[0]) and (ord(two[index]) in alpha[0]):
date = DAY[one[index]]
index += 1
index = 0
while True:
if three[index] == four[index] and (ord(three[index]) in alpha[0] or ord(three[index]) in alpha[1]) and (ord(four[index]) in alpha[0] or ord(four[index]) in alpha[1]):
break
index += 1
print("%s %s:%02d"%(date, hh, index))